Re: subprocesses lifecycle
- From: "Peter J. Holzer" <hjp-usenet2@xxxxxx>
- Date: Fri, 29 Aug 2008 21:47:04 +0200
On 2008-08-28 21:06, Eric Pozharski <whynot@xxxxxxxxxxxxxx> wrote:
Matthieu Imbert <breafk@xxxxxxxxxxxxxxxxxxxxx> wrote:
Eric Pozharski wrote:*SKIP*
In your example code, the child process stays alive after the end of
parent process. As there are probably 30 to 40 lines in /etc/passwd
and it sleeps 1 second for each line, it's not surprising that it
takes about half a minute to end and die.
Positive. My fault. I've moved B<sleep> in child before B<while> and
the child exits immediately (with regard to B<sleep> of course). What I
don't understand is why the child succesfully writes in pipe. The pipe
isn't closed if a reader exits? I don't grok pipes obviously.
When the reader exits (or more exactly, then the last reader closes the
pipe) and attempt to write into the pipe will yield a SIGPIPE. Since
your script doesn't catch SIGPIPE, this will cause your child process to
terminate. But since you didn't call $pipe->autoflush the child won't
actually try to write to the pipe until the buffer (4kB on Linux, 8kB on
most other unixes) is full - that will be after about 75 or 150 lines,
respectively.
hp
.
- Follow-Ups:
- Re: subprocesses lifecycle
- From: Eric Pozharski
- Re: subprocesses lifecycle
- References:
- subprocesses lifecycle
- From: Matthieu Imbert
- Re: subprocesses lifecycle
- From: Eric Pozharski
- Re: subprocesses lifecycle
- From: Matthieu Imbert
- subprocesses lifecycle
- Prev by Date: Re: subprocesses lifecycle
- Next by Date: Re: subprocesses lifecycle
- Previous by thread: Re: subprocesses lifecycle
- Next by thread: Re: subprocesses lifecycle
- Index(es):
Relevant Pages
|