Unix.setsid()
syntax: |
Unix.setsid() |
return: |
number - 0 for success, -1 for error.
|
description: |
Creates a new session with no terminal, most useful for having commands that, when run, immediately have the terminal prompt reappear, but continue to run in the background.
|
see: |
|
example: |
// A typical daemon program has a line like this:
#if defined(_UNIX_) Unix.setsid(); if( Unix.fork() ) Clib.exit(0); #endif
// which detaches the program from the terminal and // continues. Notice, this for line means that // only the child is running. Because the parent // has exited and the child does not have the // original file handles, the shell thinks // the program is done and goes back to the prompt. |