Re: subprocesses lifecycle
- From: Eric Pozharski <whynot@xxxxxxxxxxxxxx>
- Date: Thu, 28 Aug 2008 00:04:04 +0300
Matthieu Imbert <breafk@xxxxxxxxxxxxxxxxxxxxx> wrote:
*SKIP*
Currently, when I detect the timeout, I call die "error message". the
message is displayed, but the script does not return until subprocesses
finish (this may take several minutes, depending on what the
subprocesses do).
perl -mIO::Pipe -wle '
$pipe = IO::Pipe->new;
if(fork) {
$pipe->reader;
sleep 1;
die; };
$pipe->writer;
open $h, q|</etc/passwd|;
while($l = <$h>) {
print $pipe $l;
sleep 1; }
' ; ps -O ppid t ; sleep 40 ; ps -O ppid t
Died at -e line 6.
PID PPID S TTY TIME COMMAND
12782 1 S pts/1 00:00:00 perl -mIO::Pipe -wle ?$pipe = IO::Pipe->new;
12783 29996 R pts/1 00:00:00 ps -O ppid t
29996 29991 S pts/1 00:00:11 bash
PID PPID S TTY TIME COMMAND
12785 29996 R pts/1 00:00:00 ps -O ppid t
29996 29991 S pts/1 00:00:11 bash
See that? There's no problem with dieing (I won't comment why the
system needs more that half a minute to get rid off child (kernel?
shell? init? panic...); YMMV).
However you say that you have a problem. I suppose you have to
investigate why your script attempts to collect zombies. It should not
unless told so.
Is there a way to force the end of all subprocesses when calling die?
Second. No one can kill process which hangs in syscall till the process
gets out into userspace. So you'd be better finding why you collect.
--
Torvalds' goal for Linux is very simple: World Domination
.
- Follow-Ups:
- Re: subprocesses lifecycle
- From: Eric Pozharski
- Re: subprocesses lifecycle
- From: Peter J. Holzer
- Re: subprocesses lifecycle
- From: Matthieu Imbert
- Re: subprocesses lifecycle
- References:
- subprocesses lifecycle
- From: Matthieu Imbert
- subprocesses lifecycle
- Prev by Date: Re: Truncate an array when you have a ref to it?
- Next by Date: Re: perl multithreading performance
- Previous by thread: Re: subprocesses lifecycle
- Next by thread: Re: subprocesses lifecycle
- Index(es):
Relevant Pages
|