Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by LanX (Cardinal)
on Sep 05, 2020 at 10:36 UTC ( #11121369=note: print w/replies, xml ) Need Help??


in reply to Re^2: 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.

But you should know better.

> libtiff provides a TIFFSetWarningHandler function just for customizing error reporting.

I've recommended this myself, but I'm not sure if this interface allows a Perl sub as call back.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) Correction: to "bequeath", to "pass on" in correct English, "inherit" can't be used that way

  • Comment on Re^3: How to capture (intercept) output (warnings) of a module

Replies are listed 'Best First'.
Re^4: How to capture (intercept) output (warnings) of a module
by salva (Canon) on Sep 05, 2020 at 12:15 UTC
    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
Node Status?
node history
Node Type: note [id://11121369]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-05-07 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (93 votes). Check out past polls.

    Notices?