Subject: | Sys::Syslog crash a forked process when writing to STDERR |
When forking a process and using Sys::Syslog, any output to STDERR in
the child crash the process.
Closing STDERR and re-opening to /dev/null prevent the crash.
Attached 2 files code experiencing the trouble.
The 2 files must be in the same folder.
Start 'master.pl' look in the log and the child die when the process
write to STDERR.
Uncommenting line 10 and 11 in sub_fork.pl prevent the crash.
Probably related to perror in the module.
The module Unix::Syslog don't present the same trouble.
Bests regards.
Subject: | sub_fork.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Sys::Syslog qw(:standard :macros);
openlog( "TEST", "ndelay,pid", "local7" );
# close STDERR;
# open STDERR, ">/dev/null";
while ( 1 )
{
syslog( LOG_INFO, 'new loop in forked ($name) at ' . time );
print STDERR " force error\n";
sleep 1;
}
Subject: | master.pl |
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open3;
use Sys::Syslog qw(:standard :macros);
openlog( "TEST", "ndelay,pid", "local7" );
my $CMD = './sub_fork.pl';
$SIG{ CHLD } = 'IGNORE';
open3( undef, undef, undef, $CMD );
while ( 1 )
{
syslog( LOG_INFO, 'new loop master at ' . time );
sleep 1;
}