Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Killing the correct process Message-ID: <5713@star.cs.vu.nl> Date: 1 Mar 90 03:06:47 GMT References: <22332@adm.BRL.MIL> <5312@star.cs.vu.nl> <1212@root44.co.uk> <5382@buengc.BU.EDU> <5615@star.cs.vu.nl> <5405@buengc.BU.EDU> <5636@star.cs.vu.nl> <5410@buengc.BU.EDU> <5650@star.cs.vu.nl> <5414@buengc.BU.EDU> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Followup-To: comp.unix.questions Organization: VU Informatika, Amsterdam, the Netherlands Lines: 33 In article <5414@buengc.BU.EDU>, bph@buengc.BU.EDU (Blair P. Houghton) writes: )... ) fp = popen("/bin/ps axl","r"); ) while ( fgets(line,sizeof(line),fp) != (char *)NULL ) ) if ( uid == parse_for_uid(line) ) ) kill( parse_for_pid(line), SIGKILL ); ) pclose(fp); ) )SIG_IGN that! Between the `ps' and the kill() the user might have created new processes. Race conditions, babe. )... )>I was talking of events with much higher probability. ) )Wot? You can assign a PID to your own process? I'd like )to see that... See above. Talking about assigning your own pid: a friend of mine (Peter Valkenburg, valke@psy.vu.nl) once wrote a program called `snatch_pid'; you fed it the pid you wanted to grab, then waited an hour or so (ca. 30,000 fork()s on a VAX). The use: if some game initializes its pseudo random generator with `srand(getpid())'... ) --Blair ) "Blair -v" "Maarten -SEGV 666 :667 +1 /vmunix" -- "Belfast: a sentimental journey to the Dark Ages - Crusades & Witchburning - Europe's Lebanon - Book Now!" | maart@cs.vu.nl, uunet!mcsun!botter!maart