daemonize

Synopsis

(daemonize)

Parameters

Description

This procedure performs the following actions in order to run as a daemon:

  • fork()
  • setsid()
  • Detach from the controlling terminal
  • Redirecting standard input, standard output and standard error to /dev/null
  • Changing the current working directory to the root directory (/)

If there are any additional threads running, daemonizing is refused and an error is signalled.

Side Effects

Return Value

  • The new session id from the setsid() invocation is returned as an exact integer.

Example

$ ./scheme
> (daemonize) (sleep 10) (exit)
$