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. |