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

[ID 20010828.006] problem with sigaction and SIGALRM

Thread Next
From:
esp5
Date:
August 28, 2001 19:32
Subject:
[ID 20010828.006] problem with sigaction and SIGALRM
Message ID:
200108290204.TAA08765@rama.comp.pge.com

This is a bug report for perl from esp5@rama.comp.pge.com,
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';
eval
{
        sigaction SIGALRM, new POSIX::SigAction sub { print STDERR "SHOULD KILL
ME"; die; };

        alarm(10);

        $a = <>; # system("ftp earth.he.net");
};

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


This is wrong in a couple of respects.

First, if you uncomment the 'ftp earth.he.net', 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 
action.

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). 

Ed

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=high
---
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:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos rama 5.6 generic sun4m sparc sunw,sparcstation-20 '
    config_args=''
    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
  Compiler:
    cc='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-native',
    cppflags=''
    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 =' '
    libpth=/usr/lib
    libs=-lsocket -lnsl -ldbm -ldl -lm -lc -lposix4
    perllibs=-lsocket -lnsl -ldl -lm -lc -lposix4
    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'

Locally applied patches:
    

---
@INC for perl v5.6.1:
    /usr/local/lib/perl5/5.6.1/sun4-solaris
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.6.1:
    HOME=/home/esp5
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/opt/install/bin:/usr/local/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/bin:/usr/bin:/usr/ucb:/etc:.
    PERL_BADLANG (unset)
    SHELL=/bin/csh


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