[svlug] daemonize a bash script
Brian J. Tarricone
bjt23 at cornell.edu
Fri Jun 9 18:04:55 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
On 6/9/2006 5:54 PM, Robert Hajime Lanning wrote:
> You are thinking of the process:
> o close STDIN, STDOUT, STDERR
> o fork
> o child does setpgid
> o parent exits
> There isn't a POSIX function that does this. And the complete
> process cannot be done is the normal shell (though something
> like perl, that has access to the POSIX calls can.)
True that there's no POSIX function that does this, but daemon(3) does
do all that, and has been around since 4.4BSD (or so says the manpage).
I would venture to guess that most UNIX-ish OSes might have it. At
least you can expect Linux and (I would imagine) *BSD to have it.
> You will notice that nothing takes care of setting a new process
> group ID. This is not accessable from the shell.
Check out setsid(8). (Not to be confused with setsid(2), though
setsid(2) provides a more detailed explanation of what setsid(8) does.)
Not sure about OS availability.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v126.96.36.199 (MingW32)
-----END PGP SIGNATURE-----
More information about the svlug