Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!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: <5615@star.cs.vu.nl> Date: 19 Feb 90 19:52:11 GMT References: <22332@adm.BRL.MIL> <5312@star.cs.vu.nl> <1212@root44.co.uk> <5382@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: 27 In article <5382@buengc.BU.EDU>, bph@buengc.BU.EDU (Blair P. Houghton) writes: )... )> kill $pid >/dev/null 2>&1 ) )At this point, and I'll admit it's a rare possibility, but )not an impossibility, especially on multiprocessor machines, )what happens if the $command (see below) has already exited )and some other process (possibly on another processor) has )begun with the same pid? [...] Possible if your `$command' has been running for a *long* time and/or new processes have come and gone like crazy in the meantime... Normally it takes a few days for the pid to wrap around; conventionally MAXPID is 30,000. This value may have to be raised. )... one of my least favorite problems is that of getting )the status of a process I may not own without having to do ) ) system("ps -l##### > /tmp/foo"); /* ##### is the pid */ )... How about `fp = popen("ps -l#####", "r")'? To check if a process is alive use `kill(pid, 0)'. -- "Ever since the discovery of domain addresses in the French cave paintings [...]" (Richard Sexton) | maart@cs.vu.nl, uunet!mcsun!botter!maart