subprocesses lifecycle

P

Peter J. Holzer

I've thought (and read) a lot about this. I believe now, that my guess
is wrong.

There's no problem with zombies (and respectively waiting for childs).
As C.DeRykus clearly showed double fork doesn't help.

Now, I think, that B<perl> waits till pipe closes.

It doesn't (at least not during a close which I believe we are talking
about here - of course since Perl is a general purpose programming
language, perl can be made to wait on just about anything). A close on a
filehandle created with "open(... '...|')" waits for the child process
to terminate. If the child process forks again and terminates (as
C.DeRykus) suggested, close returns immediately, as expected.

I don't see where "C.DeRykus clearly showed double fork doesn't help".
On the contrary, I very clearly showed that it does help in a previous
posting.

That happens when writer (I intentionally say 'writer' but 'child',
because it can be child of B<init> (since double fork)) intentionally
closes pipe or just terminates.

When the writer closes the pipe, the reader will get an EOF indication.

hp
 
E

Eric Pozharski

It doesn't (at least not during a close which I believe we are talking
about here - of course since Perl is a general purpose programming
language, perl can be made to wait on just about anything). A close on a
filehandle created with "open(... '...|')" waits for the child process
to terminate. If the child process forks again and terminates (as
C.DeRykus) suggested, close returns immediately, as expected.

Positive, now I see the light. I've just checked all the cases:

=item parent doesn't wait

=item [1]

implicit close

=item [2]

explicit close with child has forked

=back

=item parent waits

=item [1]

reading from pipe

=item [2]

explicit close with child hasn't forked.

=back

=back

There's no difference if lexicals or globals were used, forking was made
with C said:
I don't see where "C.DeRykus clearly showed double fork doesn't help".
On the contrary, I very clearly showed that it does help in a previous
posting.

That was noise. Please ignore.
When the writer closes the pipe, the reader will get an EOF indication.

As Peter J. Holzer clearly showed, there's no problems closing pipes, no
reading from pipe granted. So that's not parent-child problem. That's
reader-writer problem.

BTW, it's not about Hans, it's about Matthieu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top