[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fork()ing and SIGKILL and SIGSTOP



> On Dec 2, doogie@alpha.shianet.org (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
doogie@shianet.org
http://www.geocities.com/Siliconvalley/Park/6562/


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com


Reply to: