In which case I want to capture STDOUT and STDERR of each worker "process".
And there is the source of my question: Why are you quoting "process"?
Either this is
In which case you need to 'capture' the output from STDOUT and STDERR.
In this case you don't need to 'capture' the output; you simply need to direct it to where you want it to go.
Ie. If you are going to call a subroutine that normally writes to stdout and stderr; and you want that output to end up in a file of your choosing, then point stdout and stderr to that file before you call the subroutine:
sub worker { local( *STDOUT, *STDERR ); open STDOUT, '>', 'my.log' or die $!; open STDERR, '>&STDOUT' or die $!; unmodifiable(); ## call the code that produces the output; it'll e +nd up in my.log ## the effects of the redirection get cleaned up automatically whe +n the worker ends. }
In reply to Re^8: capturing output of system call inside a thread
by BrowserUk
in thread capturing output of system call inside a thread
by that_guy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |