It is possible that this code will not work on all systems.
#!/usr/bin/perl -w # show two concurrent processes intermingling their STDERR to the same + file. # Name the program 'test_err.pl' and invoke it from command line with: # test_err.pl hs use strict; my $err_file = 'errfile.txt'; open STDERR, ">> $err_file" or die "cannot open initial $err_file: $!\n"; $SIG{'__WARN__'} = sub { syswrite STDERR, $_[0] }; my $what_to_do = shift; warn "$what_to_do hello world\n"; system( 'test_err.pl', 'abc' ) if $what_to_do eq 'hs'; my $test_string; warn "success\n" if $test_string eq 'xyz'; warn "$what_to_do goodbye world\n"; # Adds the following text to 'errfile.txt': __DATA__ hs hello world abc hello world Use of uninitialized value in string eq at C:\aa\test_err.pl line 19. abc goodbye world Use of uninitialized value in string eq at C:\aa\test_err.pl line 19. hs goodbye world
In reply to Re: multiple programs sharing redirected STDERR
by gam3
in thread multiple programs sharing redirected STDERR
by ff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |