Perhaps I wasn't very clear in my OP about what I'm trying to do. Blame it on my bad English.

Here is a second try.

I want to use pipes to read something from a small program on my system. Currently there is no way I can tell whether there was nothing to read (ie. that program wrote nothing on STDOUT or STDERR) or there was an error opening those pipes. In the second case, I would like to give the user a hint about the problem.

In other words, I have to take a different action based on whether there was an error or not. I think this is the recommended way to do programming :)

So what? According to the docs (perlvar, etc) it should have the info you need.

No. Quote from IPC::Open2:

 open2() returns the process ID of the child process. It doesn't return
 on failure: it just raises an exception matching "/^open2:/". However,
 "exec" failures in the child are not detected. You'll have to trap
 SIGPIPE yourself.

On Windows at least, that "child process" is the shell. This means that the call to open2 is always succesful! $? contains no information whatsoever about my other child process (ie. the program I'm trying to communicate with). Also, since this is Windows (no cygwin) I cannot trap SIGPIPE. Hence, no error handling is possible.

Of course, this is all documented in IPC::Open2 and perlipc but it really took me some trial-and-error doing on my own to actually grok that info. I suppose an additional note in there would have been a real time saver.

$^E is not system wide

You are right of course. My mistake.

You can always try your hand at IPC::Run3.

Thanks for the tipp. Will take a look.

In reply to Re: Re: Re: Re: Re: Re: IPC::Open2, WinXP, Perl 5.6.1 by mrd
in thread IPC::Open2, WinXP, Perl 5.6.1 by mrd

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.