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

[ID 20010828.006] problem with sigaction and SIGALRM

Thread Next
August 28, 2001 19:32
[ID 20010828.006] problem with sigaction and SIGALRM
Message ID:

This is a bug report for perl from,
generated with the help of perlbug 1.33 running under perl v5.6.1.

[Please enter your report here]

This is in regards to the program:

use POSIX ':signal_h';
        sigaction SIGALRM, new POSIX::SigAction sub { print STDERR "SHOULD KILL
ME"; die; };


        $a = <>; # system("ftp");

print STDERR "AM I HERE!!!\n";

This is wrong in a couple of respects.

First, if you uncomment the 'ftp', it doesn't hinder the 
process in *any* way. ie: the loop keeps on executing.

However, when '$a = <>' is active (as written) then the alarm *is* triggered, 
but the process doesn't die(?). In other words, the action as an argument to 
POSIX::SigAction is IGNORED. It just registers the fact that there *is* an 

Very very weird. What I need is an ALRM signal that kills any processes 
remaining inside an eval. Should be easy, but for some reason SA_RESTART was 
turned on *by default* some time back in the dark ages around 5.005_03 (which 
is itself sort of bizarre). 

It notes this as a workaround in the docs -

> If your system has the sigaction() function then signal handlers are
> installed using it.  This means you get reliable signal handling.  If
> your system has the SA_RESTART flag it is used when signals handlers are
> installed.  This means that system calls for which restarting is supported
> continue rather than returning when a signal arrives.  If you want your
> system calls to be interrupted by signal delivery then do something like
> this:               
    > use POSIX ':signal_h';
    > my $alarm = 0;  
    > sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 }
        > or die "Error setting SIGALRM handler: $!\n";

Now this would be really nice, except it *doesn't* work.

Anyways, to me this is confusing. Why, by default would you want your 
sub-processes to *not* die on the event of a signal (like control-C). Surely the
default should be the system default (which at least on solaris and linux the
processes die with their parent). 


[Please do not change anything below this line]
Site configuration information for perl v5.6.1:

Configured by dehc at Wed Aug 22 13:51:31 PDT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos rama 5.6 generic sun4m sparc sunw,sparcstation-20 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    cc='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    ccversion='WorkShop Compilers 5.0 98/12/15 C 5.0', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='/opt/SUNWspro/bin/cc', ldflags =' '
    libs=-lsocket -lnsl -ldbm -ldl -lm -lc -lposix4
    perllibs=-lsocket -lnsl -ldl -lm -lc -lposix4
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G'

Locally applied patches:

@INC for perl v5.6.1:

Environment for perl v5.6.1:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About