Skip Menu |

This queue is for tickets about the Sys-Syslog CPAN distribution.

Report information
The Basics
Id: 49100
Status: rejected
Priority: 0/
Queue: Sys-Syslog

People
Owner: Nobody in particular
Requestors: fabrice [...] dulaunoy.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



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; }
Subject: Re: [rt.cpan.org #49100] Sys::Syslog crash a forked process when writing to STDERR
Date: Mon, 18 Apr 2011 15:35:13 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Hello, Apologies for the long delay before answering. Fabrice DULAUNOY wrote via RT: Show quoted text
> 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.
Allow me to question the use of open3() with undef filehandles. I don't see how this can work. Using filehandles, your examples don't crash here. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
Subject: Re: [rt.cpan.org #49100] Sys::Syslog crash a forked process when writing to STDERR
Date: Mon, 18 Apr 2011 17:02:44 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: DULAUNOY Fabrice <fabrice [...] dulaunoy.com>
On Mon, 18 Apr 2011 09:35:10 -0400 "Sébastien Aperghis-Tramoni via RT" <bug-Sys-Syslog@rt.cpan.org> wrote: Mister Aperghis-Tramoni, The small example was a little "extreme". In my code the file-handles ( specifically the STDERR ) is dynamically allocated. ( some fork use the STDERR, some not ) What is strange is that if the STDOUT is undef and I write in STDOUT from the child, the process don't crash. But for STDERR it crash. It is that difference between STDERR and STDOUT that is bothering me. Best regards Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=49100 > > > Hello, > > Apologies for the long delay before answering. > > > Fabrice DULAUNOY wrote via RT: >
> > 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.
> > > Allow me to question the use of open3() with undef filehandles. I > don't see how this can work. > Using filehandles, your examples don't crash here. > > > -- > Sébastien Aperghis-Tramoni > > Close the world, txEn eht nepO. > >
-- +-----------------------------------------------------+ / |\ _,,,---,,_ /| / /,`.-'`' -. ;-;;,_ / | / |,4- ) )-,_. ,\ ( `'-' / | / '---''(_/--' `-'\_) / | +-----------------------------------------------------+ | | Dulaunoy Fabrice | | | | | | e-mail : fabrice@dulaunoy.com | | | : fabrice.dulaunoy@cegeka.be | | | | / | PGP fingerprint : | / | 9DD6 37BA D868 8F26 5283 CFA9 E9B3 49D8 7AC1 7E57 | / | Unix *is* userfriendly. | / | It's just selective which users it is friendly to. |/ +-----------------------------------------------------+
Subject: Re: [rt.cpan.org #49100] Sys::Syslog crash a forked process when writing to STDERR
Date: Fri, 22 Apr 2011 01:18:19 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Fabrice Dulaunoy wrote via RT: Show quoted text
> The small example was a little "extreme". > > In my code the file-handles ( specifically the STDERR ) is > dynamically allocated. ( some fork use the STDERR, some not ) > > What is strange is that if the STDOUT is undef and I write in > STDOUT from the child, the process don't crash. > But for STDERR it crash.
I am unable to reproduce this with the various versions of Perl I have by hand, using allocated of undef filehandles with open3(). What is your version of Perl? Show quoted text
> It is that difference between STDERR and STDOUT that is bothering me.
There are some well-known differences between these streams WRT tie() ing, for example. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
Subject: Re: [rt.cpan.org #49100] Sys::Syslog crash a forked process when writing to STDERR
Date: Fri, 14 Sep 2012 14:25:04 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Taking a new look on this ticket, I saw that I can indeed reproduce the problem, but Sys::Syslog can be removed from the equation and the problem still occurs. Which really means that the root cause is because the file handles are all undefined. And indeed, searching on Perl RT reveals the following tickets: - IPC::Open3 doesn't vivify an err filehandle » https://rt.perl.org/rt3/Ticket/Display.html?id=31738 - IPC::Open3 does not auto-create an error handle » https://rt.perl.org/rt3/Ticket/Display.html?id=55570 The documentation has been updated to reflect that you must explicitly provide a valid file handle for STDERR. » http://perldoc.perl.org/IPC/Open3.html -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.