Bug#495788: perl: pending signals are processed in both the parent and child process after a fork()

Dominic Hargreaves dom at earth.li
Sun Apr 28 16:53:33 UTC 2013


Control: tags -1 + confirmed upstream fixed-upstream

On Wed, Aug 20, 2008 at 02:38:10PM +0200, Bas van Sisseren wrote:
> Package: perl
> Version: 5.10.0-13
> Severity: normal
> 
> When system-calls are processed, all signals are enqueued until the next perl
> instruction is executed. When the fork() system-call is processed, and the
> parent receives a signal just before the fork() call, both the parent and the
> child will process the enqueued signals.
> 
> Imho, the enqueued signal-list should be flushed when we are the child process
> after the fork().
> 
> Example code:
> ==============================
> use strict;
> use Time::HiRes qw( alarm );
> 
> my $ppid = $$;
> my $fork = 0;
> $SIG{ALRM} = sub {
>         print "[SIGALRM] ppid=$ppid pid=$$ fork=$fork\n" if $$ != $ppid;
>     };
> 
> for (1..10000) {
>     alarm(0.0002 + rand() * 0.0002);
>     $fork = 1;
>     my $pid = fork();
>     $fork = 0;
>     if (!defined $pid) {
>         warn "fork(): $!\n";
>     } elsif ($pid == 0) {
>         exit(0);
>     }
> }
> 
> sleep(1);
> ==============================

This doesn't happen in blead, so tagging bug appropriately; it'll be
fixed in a future Debian release.

Dominic.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)




More information about the Perl-maintainers mailing list