in reply to Unexpected termination on "print"
the exit value after termination is 141, which means nothing to me.
Then perhaps you should read about $? ?
If I change the print statement to print {$proc->stdin} "text\n" the it appears as if perl tries to run the statement twice!
No, it is just that in print {$proc->stdin} "text\n" there are two statements in that one line. The braces actually constitute a block and so $proc->stdin is a full statement, not just an expression. So the debugger stops for that statement first and then stops for the print statement after that.
But back to your primary question. The reason printing to a pipe usually causes a process to exit is because all readers of that pipe have now closed their handle (usually because they have exit()ed) and so the writing process gets sent SIGPIPE. This behavior should be mentioned briefly in "man 2 write" and should be covered more extensively by "man 7 pipe".
And your exit value confirms that this is the cause in your specific case.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unexpected termination on "print" (pipe)
by mlawren (Sexton) on Aug 14, 2015 at 20:35 UTC | |
by tye (Sage) on Aug 14, 2015 at 20:50 UTC | |
by mlawren (Sexton) on Aug 14, 2015 at 21:22 UTC | |
by afoken (Chancellor) on Aug 14, 2015 at 22:27 UTC | |
by AnomalousMonk (Archbishop) on Aug 14, 2015 at 22:29 UTC | |
by mlawren (Sexton) on Aug 15, 2015 at 10:41 UTC | |
|