Same thing on Unix as well:

What happens is this: perl(2) command exists, thus the open succeeds and perl(2) _is_ running. The failure itself from perl(2) (exiting), the invoking perl(1) setting $?, etc, does happen later, i.e. on the first print (*) on that handle.

The fix of course is doing as romandas suggests.

(*) make that actual use of the underlying handle. So I don't known what happens in case of empty print SORT "". Also it depends on whether the handle does buffering or directly talks to the other process perl(2). Write a small test case and ask your setup how it will behave :).

If the invoked command dies after reading a bit, the error will be visible to perl(1) even later (in case of perl(2), it dies _without_ reading from STDIN of course).


In reply to Re: open to pipe fails with exit on Windows by jakobi
in thread open to pipe fails with exit on Windows by bluebloodpole

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.