[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: How to properly daemonize?
On Fri, Jul 14, 2017 at 11:58:49PM -0400, Ken Hornstein wrote:
> - Call fork() in parent, and then use sigwait() to wait for SIGCHLD or SIGUSR1
> - In the child, perform library initialization. If it fails, print out
> the error message on stderr and exit. If it succeeds send a SIGUSR1 to
> the parent and then perform the rest of the daemonization steps as discussed
> - If the parent gets a SIGCHLD, call waitpid() and exit with the exit code
> that the child exited with. If the parent gets a SIGUSR1, then exit normally.
A better design would be to just use a pipe and write the status to
that. No signals necessary. Parents knows if the status read from the
pipe is bad OR you get EOF, initialisation went wrong.
Main Index |
Thread Index |