home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!panther!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: How to check if a given process ID is still around?
- Message-ID: <mcook.722017897@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <1992Nov17.000624.21281@schbbs.mot.com>
- Date: Tue, 17 Nov 1992 16:31:37 GMT
- Lines: 23
-
- mmuegel@next3.corp.mot.com (Michael S. Muegel) writes:
-
- >Is there way (not using ps(1)) to see if a given PID is active? I am writing
- >a scheduler that spawns children to performan various tasks and I want the
- >scheduler to know if the child has quit. This way I will never run two of
- >the same child "modules" simulataneously. I know I could use IPC but the
- >PID trick would be an easy kludge.
-
- if (!kill(0, $pid) && $! =~ /No such process/)
- {
- print "$pid is dead.\n";
- }
- else
- {
- print "$pid is still alive.\n";
- }
-
- You might also consider using SIGCHILD.
-
- >Thanks!
- >-Mike
-
- You're welcome, Mike.
-