Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by salva (Canon)
on Sep 05, 2020 at 12:15 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2021-04-20 16:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found