Killing the correct process

Maarten Litmaath maart at cs.vu.nl
Tue Feb 20 06:52:11 AEST 1990


In article <5382 at buengc.BU.EDU>,
	bph at 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 at cs.vu.nl,  uunet!mcsun!botter!maart



More information about the Comp.unix.questions mailing list