in reply to Could not catch all children after fork, some of them never end

This var is checked by each child
No it's not. Memory is not shared between parent and child processes. You want to have the parent notice the signal, signal the children, and wait for them.
  • Comment on Re: Could not catch all children after fork, some of them never end

Replies are listed 'Best First'.
Re^2: Could not catch all children after fork, some of them never end
by krabbl (Initiate) on Mar 13, 2013 at 12:43 UTC

    I thought its a fork so everything should be cloned until this position and every child should get the SIG INT (the sig handler is defined before the fork) or am I wrong? Because the text msg (print cmd in sig handler) shows up for every single child and even some childs are finishing as expected after pressing ctrl-c.

      I think I may have oversimplified in my answer. I know that when you press control-c, the signal is delivered to the process currently attached to the terminal. Maybe the children take over from the parent when it exits if you didn't close STDIN and STDOUT before forking, but I would have to look it up and play around a bit to figure out exactly what happens. Sorry.