Is there a way to stop a child process inheriting signal handlers?
1,349 views
Skip to first unread message
sp...@potato.field
unread,
Nov 1, 2016, 10:29:14 AM11/1/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I have a forking server and I need child processes to call a different signal
handler than the parent for various signals. Now obviously I could reset them
immediately after fork() but there will always be that small window where the
child could get a signal and call the parent handler before signal() or
sigaction() is called, or alternatively I could set them before but of course
that then messes up the parent signal handling for a small period which is
equally unwanted.
So my question is , is there a way to stop the child processes inheriting
signal handlers or even better is there a way to preset the signal handlers
for any child processes yet to be created? There doesn't seem to be any
appropriate sigaction() flags to allow this. My question is for Linux, but if
there's a generic Unix solution so much the better.
Thanks for any help
--
Spud
Barry Margolin
unread,
Nov 1, 2016, 10:46:57 AM11/1/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Maybe something like this:
Block signals
Fork
In child, reset signal handlers
Unblock signals in both processes
--
Barry Margolin, bar...@alum.mit.edu Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
sp...@potato.field
unread,
Nov 1, 2016, 11:00:28 AM11/1/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
On Tue, 01 Nov 2016 10:46:54 -0400
Barry Margolin <bar...@alum.mit.edu> wrote:
>Maybe something like this:
>
>Block signals
>Fork
>In child, reset signal handlers
>Unblock signals in both processes
Thanks. I'd completely forgotten that you can block signals. Time to get
Stevens off the shelf for a refresher!