Re: subprocesses lifecycle
- From: "Peter J. Holzer" <hjp-usenet2@xxxxxx>
- Date: Sat, 30 Aug 2008 10:43:36 +0200
On 2008-08-29 18:58, Eric Pozharski <whynot@xxxxxxxxxxxxxx> wrote:
C.DeRykus <ced@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
*SKIP*
open my $fd, "/some/task & |"
or die...
However, child subprocesses would then need to be foregrounded with
SIGCONT if the parent wants to kill them before exiting.
Backgrounding doesn't work. I meant it doesn't matter.
time perl -wle '
open my $h, q{(sleep 1 ; /bin/echo -en xyz ) & |} or die $!;
print `ps --cols 60 -O ppid t`;
print <$h>;
You are waiting for input here - of course you can read "xyz\n" only
when the client writes it. So here is your 1 second delay. That has
nothing to do with close.
print `ps --cols 60 -O ppid t`;'[...]
real 0m1.277s
user 0m0.084s
sys 0m0.080s
If you remove print <$h>; the parent will exit immediately, but the
child will continue to run.
% time perl -wle '
open my $h, q{(sleep 1 ; /bin/echo -en xyz )& |} or die $!;
print `ps --cols 60 -O ppid t`;'
ps --cols 60 -O ppid t
PID PPID S TTY TIME COMMAND
2287 27943 R pts/3 00:00:00 perl -wle ?open my $h, q{(sl
2288 2287 Z pts/3 00:00:00 [sh] <defunct>
2289 2287 R pts/3 00:00:00 ps --cols 60 -O ppid t
2290 1 S pts/3 00:00:00 sh -c (sleep 1 ; /bin/echo -
2291 2290 S pts/3 00:00:00 sleep 1
27943 27942 S pts/3 00:00:00 zsh
perl -wle 0.00s user 0.01s system 71% cpu 0.011 total
PID PPID S TTY TIME COMMAND
2290 1 S pts/3 00:00:00 sh -c (sleep 1 ; /bin/echo -
2291 2290 S pts/3 00:00:00 sleep 1
2292 27943 R pts/3 00:00:00 ps --cols 60 -O ppid t
27943 27942 S pts/3 00:00:00 zsh
hp
.
- References:
- subprocesses lifecycle
- From: Matthieu Imbert
- Re: subprocesses lifecycle
- From: Eric Pozharski
- Re: subprocesses lifecycle
- From: Matthieu Imbert
- Re: subprocesses lifecycle
- From: Hans Mulder
- Re: subprocesses lifecycle
- From: C.DeRykus
- Re: subprocesses lifecycle
- From: Eric Pozharski
- subprocesses lifecycle
- Prev by Date: Re: subprocesses lifecycle
- Next by Date: question about data structures - what does $# mean?
- Previous by thread: Re: subprocesses lifecycle
- Next by thread: Re: subprocesses lifecycle
- Index(es):
Relevant Pages
|