develooper Front page | perl.perl5.porters | Postings from March 2001

Thread::Signal bug related to fork()

Thread Next
From:
David M. Lloyd
Date:
March 30, 2001 09:13
Subject:
Thread::Signal bug related to fork()
Message ID:
Pine.LNX.4.21.0103301053050.3153-100000@homebody.freemm.org
I think the bug I am encountering with Thread::Signal is related to fork
in some way.

Take the following program:

####################
#!/usr/local/bin/perl

use strict;
use warnings;

$| = 1;

use Thread::Signal;

for my $sig (keys %SIG) {
    next if ($sig =~ /__/);
    print "Hooking signal $sig\n";
    $SIG{$sig} = sub { print "Signal $sig\n" };
}

print "Hello.  Before fork...\n";

if (my $pid = fork) {
    # Parent, so exit
    print "After fork in parent $$.\n";
    exit 0;
} elsif (defined($pid)) {
    # Child, yay
    print "After fork in kid $$.\n";
} else {
    die "Can't fork daemon: $!\n";
}

sleep 20 until (0);

exit 0;
# END
####################

On Linux, this output is generated:

Hooking signal TRAP
Hooking signal NUM40
Hooking signal PROF
...
Hooking signal WINCH
Hooking signal RTMIN
Hooking signal FPE
Hello.  Before fork...
After fork in parent 19097.
After fork in kid 19100.

Then the child is forked.  If I try to kill it:

[usrodl@tomservo test]$ kill -TERM 19100
[usrodl@tomservo test]$

I get nothing... the child isn't getting signals at all.

If I _don't_ fork, the parent gets signals just fine.

Same result on Solaris 2.8.  I've tried Perl 5.6.0 and Perl 5.6.1trial3 on
Linux, and 5.6.0 on Solaris:

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.16-22enterprise, archname=i686-linux-thread-64all 
    uname='linux tomservo 2.2.16-22enterprise #1 smp fri oct 6 15:44:06 cdt 2000 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=define useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=define uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.96 20000731 (Red Hat Linux 7.0)
    cppflags='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -DDEBUGGING'
    ccflags ='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.1.92.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING USE_THREADS USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Mar 26 2001 12:07:54
  @INC:
    /usr/lib/perl5/5.6.0/i686-linux-thread-64all
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i686-linux-thread-64all
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl
    .



Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.2.16-22enterprise, archname=i686-linux-thread-64all
    uname='linux tomservo 2.2.16-22enterprise #1 smp fri oct 6 15:44:06 cdt 2000 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=define useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -DDEBUGGING'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=/lib/libc-2.1.92.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING USE_THREADS USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Locally applied patches:
  	v5.6.1-TRIAL3
  Built under linux
  Compiled at Mar 28 2001 15:20:04
  @INC:
    /usr/local/lib/perl5/5.6.1/i686-linux-thread-64all
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/i686-linux-thread-64all
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl
    .

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris-thread-64int
    uname='sunos ohno 5.8 generic_108528-03 sun4u sparc sunw,ultra-5_10 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=define useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef
usesocks=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-D_REENTRANT -I/usr/local/include -I/opt/gnu/include -DDEBUGGING'
    ccflags ='-D_REENTRANT -I/usr/local/include -I/opt/gnu/include -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/gnu/lib -L/opt/SUNWspro/SC5.0/lib '
    libpth=/usr/local/lib /opt/gnu/lib /opt/SUNWspro/SC5.0/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib -L/opt/gnu/lib -L/opt/SUNWspro/SC5.0/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING USE_THREADS USE_64_BIT_INT USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Built under solaris
  Compiled at Mar 26 2001 14:24:30
  @INC:
    /usr/lib/perl5/5.6.0/sun4-solaris-thread-64int
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/sun4-solaris-thread-64int
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl
    .

- D

<david@freemm.org>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About