> On Dec 2, [EMAIL PROTECTED] (Adam Heath) wrote: > > I am writing a program that listens on several ports, using fork() to start > > a separate thread for each port. I want to be able to kill each of the > > child processes when the master parent terminates. I do not know how to > > implement this. I have tried signal(), and wait(), and neither will allow > > trapping of SIGKILL and SIGSTOP. I have registered a function with > > atexit(), and that is not run either. > > Neither SIGKILL or SIGSTOP can be caught -- otherwise you could > write a program that couldn't be stopped without rebooting. > > > I know this can be done, because when PPPD is started, and I issue the > > command "kill <PPPD pid>", PPPD runs the disconnect script before quitting. > > "kill <pid>" sends SIGTERM, which is probably what you are looking for. > > The general concept would be for the master to keep track of all of the > child pids, and then when receiving SIGTERM, kill the children (kill()), > and then wait for them to terminate (wait() or waitpid()). > > Steve Greenland
After I sent this, I got the bright idea to type "man kill" and discovered this. Everything is now working the way I wanted it to. Now, I am going to make it created a PID file for start-stop-daemon. Adam Heath [EMAIL PROTECTED] http://www.geocities.com/Siliconvalley/Park/6562/ -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED]