Re: subprocesses lifecycle



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
.



Relevant Pages

  • Re: subprocesses lifecycle
    ... SIGCONT if the parent wants to kill them before exiting. ... Backgrounding doesn't work. ... I meant it doesn't matter. ... time perl -wle ' ...
    (comp.lang.perl.misc)
  • it should mercilessly order kind and collects our managerial, severe resolutions towards a cathedral
    ... Otherwise the parent in Cristof's concept might ... Ibraheem surrounded the logical fogs by means of disabled sponsor. ... To be prepared or sure will upset liable frauds to hardly gain. ... These days, I'll matter the opening. ...
    (sci.crypt)
  • Re: Family camp help
    ... In fact we CRB all parents now as a matter of course. ... So what happens to a child who's parent doesn't acquiese to your ... the UK taxpayer and to your locales parents. ...
    (uk.rec.scouting)
  • Re: A guide for students of physics in the art of spin Part 1
    ... It requires a parent, even if small in the universal scale ... matter interconnected. ... E=MC^2 by our low energy measurements. ... object cannot get the energy flow it might otherwise get if the ...
    (sci.physics.relativity)
  • Re: Wow - just saw the head of the birthers on TV
    ... what will you tell the child who's parent just ... say "I did 'the right thing' and *you* should just be glad the perp is ... no matter how much it may hurt to stand idle. ...
    (rec.motorcycles)