Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Alas this doesn't fix the core problem of the subprocess hanging in the read loop. I'll modify the example a bit to make the misbehavior clearer, incorporating some of your suggestions & some from other nodes:
perl -MIPC::Open3 -MPOSIX=WNOHANG -e "open CPYOUT,'>&STDOUT';open CPYE +RR,'>&STDERR';$pid=open3(\*IN,'>&CPYOUT','>&CPYERR','perl','-pe','END + {warn qq(Finished\n)}');close CPYOUT;close CPYERR;print IN 'Hello',$ +/;close IN;sleep 3;waitpid $pid,WNOHANG"
The one liner is getting long with it's new features:

The subprocess has an END block printing that it is done. In "real life" the sub-process reads all the input, then prints a bunch of output when it is done reading all the input. The purpose of this question is figuring out how get the subprocess to move beyond its read loop.

The parent is closing its copies of the output handles as suggested in another thread. We do see output on the screen, and the parent eventually exits anyway, so the child is not blocking on output.

Also added a waitpid, which doesn't reap, and I end up with a zombie process. Only it isn't truly a zombie, it is still waiting on stdin, active and parentless. Which explains why wait/waitpid "hang"- the child hasn't exited.


In reply to Re^3: IPC::Open3 STDIN never sees eof on win32? by Yary
in thread IPC::Open3 STDIN never sees eof on win32? by Yary

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found