Reputation: 3562
I want to write a robust daemon in perl that will run on Linux and am following the template described in this excellent answer. However there are a few differences in my situation: First I am using Parallel::ForkManager start() and next
; to fork on an event immediately followed by exec('handle_event.pl')
In such a situation, I have the following questions:
exec('handle_event.pl')
will the handlers get inherited across the exec (I know that they are inherited across the fork
)?handle_event.pl
will this definition override the one defined in the parent?Thank you
Upvotes: 2
Views: 2475
Reputation: 8387
The exec
replaces the whole process code with the code that will be executed. As signal handlers are code in the process image, they cannot be inherited across an exec
, so exec
will reset the signal handling dispositions of handled signals to their default states (ignored signals will remain ignored). You will therefore need to install any signal handling in the exec
ed process when it starts up.
Upvotes: 4
Reputation: 754730
When you fork, the child process has the same signal handlers as the parent. When you exec, any ignored signals remain ignored; any handled signals are reset back to the default handler.
Upvotes: 6