Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Problem with IPC::Open2 when STDOUT/STDERR are redirected (!local)

by Zaxo (Archbishop)
on Feb 29, 2008 at 11:09 UTC ( [id://671146]=note: print w/replies, xml ) Need Help??


in reply to Re: Problem with IPC::Open2 when STDOUT/STDERR are redirected (!local)
in thread Problem with IPC::Open2 when STDOUT/STDERR are redirected

++tye, for accuracy, but --perl for correctness. The filenos for clib stdin, stdout and stderr should not be hardwired. I recall showing you, a few years ago, how to make stderr have file descriptor 3 on linux and still behave properly there.

I'm not very up-to-date on either linux or perl at the moment, but I'll check and see if my preferred conventions still hold.

After Compline,
Zaxo

  • Comment on Re^2: Problem with IPC::Open2 when STDOUT/STDERR are redirected (!local)

Replies are listed 'Best First'.
Re^3: Problem with IPC::Open2 when STDOUT/STDERR are redirected (fd 0..2)
by tye (Sage) on Feb 29, 2008 at 15:41 UTC
    how to make stderr have file descriptor 3 on linux and still behave properly there

    When you fork exec, the only I/O units that the process keeps are the file descriptors. Whatever you have for file descriptor 0 will be stdin/STDIN after exec, no matter what you were using it for and no matter what conventions you set up for how you use it. Whatever your conventions are, they don't change how fork/exec work nor how the process initialization sets up stdin in C (which is what Perl uses to set up its STDIN).

    So if you have conventions that make it so your code will use fd 3 for stderr when you've set it up for that, those have no impact on what the standard process initialization code will do when you fork/exec nor how the child process will set up stderr based on what fd 2 was in the parent process (which will also mean that your code would use fd 2 as stderr when the process is freshly initialized). So your conventions can't "fix" Perl so that, when somebody buries fd 1 with local(*STDOUT) Perl can somehow cause child processes to not use that buried fd 1 as their stdout.

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://671146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found