suppres SIGHUP on forking#25
Conversation
|
Maxim Zakharov notifications@github.com writes:
Would it? I'm surprised. If so, we have a problem: the caller might expect a SIGHUP and hope to Cheers, |
|
But if the caller to do not expect it default action for SIGHUP is to terminate the process. glibc's implementation of daemon() doesn't not block SIGHUP, while freebsd's does: https://svnweb.freebsd.org/base/stable/9/lib/libc/gen/daemon.c?view=markup Also both versions call setsid() straight after fork(), so if you decide not to block SIGHUP it makes sense to move setsid() call up after fork() as it insulates of receiving SIGHUP from control terminal once executed. |
|
On Thu, Jul 30, 2015 at 05:57:40PM -0700, Maxim Zakharov wrote:
Are you saying that moving the setsid() prevents the SIGHUP? If so, David Gibson | I'll have my music baroque, and my code |
|
Moving setsid() set the possibility of SIGHUP to a minimum, but not prevents it completely. |
|
Maxim Zakharov notifications@github.com writes:
Ah, I see! So, if the parent is already the session group leader, then it will My complaint with your version since it might miss a real SIGHUP. Most (This is untested, but gives the idea...) Cheers, diff --git a/ccan/daemonize/daemonize.c b/ccan/daemonize/daemonize.c
/* Don't hold files open. /
|
We need to suppress SIGHUP until we set up as the parent's exit on forking would throw it.