fletcher_the_dog has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that even after the child process is dead the parent process keeps going. According to the documentation for kill:use strict; my $pid = fork(); if (!$pid) { print "I am the child process\n"; system "emacs"; # this is just an example I am not really launching +emacs print "Child process should end now\n"; exit 0; } else { print "I am the parent of $pid\n"; while (kill 0,$pid) { print "My child is still alive\n"; sleep(3); # wait a little bit } print "Parent process done\n"; } __OUTPUT__ $ perl script.pl I am the child process I am the parent of 1324 My child is still alive My child is still alive My child is still alive Child process should end now My child is still alive My child is still alive etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using 'kill' to see if a process is stil alive
by Zaxo (Archbishop) on Jul 29, 2004 at 19:22 UTC | |
|
Re: Using 'kill' to see if a process is stil alive
by ambrus (Abbot) on Jul 29, 2004 at 19:05 UTC |