note
sgifford
<ul>
<li>This program doesn't work when run as root either.
<li>I believe you're thinking of SIGKILL. SIGTERM is a perfectly normal signal. If I change the <code>kill</code> command to just send a normal signal to <code>$kidpid</code>, then the child process prints the TERM message, but not the grandchildren. Similarly, if you make the <code>sleep</code>s a little longer, you can send TERM signals by hand to individual grandchildren, and they print the message.
</ul>
298613
298668