Below is a simple example of a more complex mulit-platform perl script that I have
written. Basically, a child process(thread) needs to be able to redirect STDOUT and
STDERR to files. When the child process does so in the script below I get STDERR &
STDOUT print statements in the files, but the STDOUT from the system command still
goes to the screen. The STDERR seems to go correctly to the file. I was able to dig
up a bug report that described a similar problem. Is there a version of activeperl
that fixes this problem? If not, is there a workaround?
It only happens when the fork() call is involved and it works properly when I use the
cygwin port of perl.
I have tried it on activeperl 5.6.1 build 628 & 633.
Thanks,
Nathan Goff
Build Engineer
Mentor Graphics Corp
$SIG{'CHLD'} = 'IGNORE';
$ERR_FILE = "c:\\tmp\\err.txt";
$OUT_FILE = "c:\\tmp\\out.txt";
unlink($ERR_FILE);
unlink($OUT_FILE);
while(TRUE)
{
#print STDOUT "parent\n";
#print STDERR "parent\n";
#open(SAVEOUT, ">&STDOUT");
#open(SAVEERR, ">&STDERR");
close(STDOUT);
close(STDERR);
$pid1 = fork();
if($pid1 == 0)
{
run();
exit(0);
}
sleep(5);
}
sub run
{
open(SAVEOUT, ">&STDOUT");
open(SAVEERR, ">&STDERR");
open(STDERR,">>${ERR_FILE}");
open(STDOUT,">>${OUT_FILE}");
print STDOUT "child_file_out\n";
print STDERR "child_file_err\n";
system("xcopy");
close(STDERR);
close(STDOUT);
open(STDOUT, ">&SAVEOUT");
open(STDERR, ">&SAVEERR");
print STDOUT "child_screen_out\n";
print STDERR "child_screen_err\n";
}
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs