Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: How to capture (intercept) output (warnings) of a module

by salva (Canon)
on Sep 05, 2020 at 12:15 UTC ( [id://11121371]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to capture (intercept) output (warnings) of a module
in thread How to capture (intercept) output (warnings) of a module

I've always been under the impression that redirections are inherited to a child process.

Well, redirections are inherited by child processes... sometimes!

It depends on whether the redirection target exists at the OS level or not. In practice, that means whether a OS file descriptor is associated to the Perl file handle or not.

When you open a perl scalar as a file (as in, open my $fh, '>', \$data), no file is opened at the OS level, and no file descriptor becomes associated to the file handler. So, forked processes or just C libraries calling C stdio functions (or the OS syscalls in any other way) are not going to see it and may fail, or in the case of stderr, stdin or stdout, just use the default streams.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-03-29 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found