[uClinux-dev] Daemonize a process

Stuart MacDonald stuartm at connecttech.com
Thu Mar 13 10:43:32 EST 2003

From: "Kendrick Hamilton" <hamilton at sedsystems.ca>
> If I remember correctly, the reason why your process is killed is because
> it recevies a signal (hang up I think). The default hang up signal action
> for a process is to abort the process. You can change the signal handler
> so it ignores the hang up signal. There may be a few other signal handlers
> you may need to alter. Look at man 7 signal.

A process dies when you log out because all processes under your
shell are killed as part of the death of the shell. Ignoring signals,
or attempting to handle them does not change this fact.

I believe the actual sequence is the process gets a SIGTERM and then
a SIGKILL. KILL is not catchable or ignorable.

In any case, this is why daemonisation is handy; it severs the
connection between the process and your shell, often reparenting
itself so that init is its parent instead. When you log out, the
process is no longer part of your shell's children/process group, and
is not sent SIGTERM/KILL.


More information about the uClinux-dev mailing list