Path: utzoo!utgpu!watserv1!watmath!att!dptg!pegasus!mpl From: mpl@pegasus.ATT.COM (Michael P. Lindner) Newsgroups: comp.unix.questions Subject: Re: How do you handle while(1) fork(); ? Message-ID: <4900@pegasus.ATT.COM> Date: 12 Jul 90 20:04:42 GMT References: <841@massey.ac.nz> <1990Jul11.115612.2155@aucs.uucp> <4261@uqcspe.cs.uq.oz.au> Reply-To: mpl@pegasus.ATT.COM (Michael P. Lindner) Organization: AT&T Bell Labs NJ USA Lines: 36 In article <4261@uqcspe.cs.uq.oz.au> rhys@batserver.cs.uq.oz.au writes: >peter@aucs.uucp (Peter Steele) writes: >>ARaman@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. deleted stuff How about something like: main(argc, argv) int argc; char *argv[]; { setuid(atoi(argv[1])); kill(-1, 9); } With appropriate checks for validity of arguments and return codes, of course. Man page for kill(2)... "if pid is -1, and the effective user ID of the sender is not super-user, sig will be sent to all processes excluding proc0 and proc1 whose real user ID is equal to the effective user ID of the sender. When the above program is run as super-user, with the offender's numerical user ID as its argument, it makes its user ID the same as the offender's and kills all processes belonging to that user. Not sure if this'll work on non-System V machines. Mike Lindner attmail!mplindner