How do you handle while(1) fork(); ?

Buster Irby rli at buster.irby.com
Fri Jul 13 07:12:18 AEST 1990


rhys at batserver.cs.uq.oz.au (Rhys Weatherley) writes:

>peter at aucs.uucp (Peter Steele) writes:

>>ARaman at massey.ac.nz (A.V. Raman) writes:

>>>Is there any way to kill all instances of a process that has the
>>>following piece of code in it without having to bring the system down?

>>>   while (1)
>>>      fork();

>>>Any help (by email) would be appreciated.

>>I think a summary of responses to this question would be appreciated.
>>We've had students do this on many occasions on our Sun.

>I would also be interested in a summary, but how about this one:

>	while (!fork ())
>	  {
>	    /* some non-important code */
>	  }
>	/* some "clean-up" code */
>	exit (0);

I don't know about Sun's, but on System V you can use the fuser command
to kill all processes attacked to the tty or any other common resource
which is shared by all of the children.  It can be used to effectively
perform a kill process group operation on all processes attatched to a
specific tty as follows:

$ fuser -k /dev/tty?? 

P.S. You must be root to execute this as it sends the SIGKILL signal to
the processes.
-- 
Buster Irby  buster!rli



More information about the Comp.unix.questions mailing list