develooper Front page | perl.perl5.porters | Postings from February 2008

interrupting system() with signal depends on signal handler

Thread Next
From:
Steffen Ullrich
Date:
February 26, 2008 00:04
Subject:
interrupting system() with signal depends on signal handler
Message ID:
fq0h5l$vv5$1@ger.gmane.org
Hi,
take the following simple code:

  1 #$SIG{ALRM} = sub { syswrite(STDOUT,"lala\n",5); }; # system() stops
  2 $SIG{ALRM} = sub { print STDOUT "lala\n" }; # system() continues
  3 alarm(1);
  4 system( 'sleep 100' );

If I use the signal handler in line 2 it gets triggered like expected after
one second and the system() call continues. If I use instead the handler
in line 1 the signal handler gets triggered and system() gets interrupted.

This is checked with perl5.8.8,perl 5.8.7 and perl5.10 on MacOSX and with
perl5.8.8 on Linu and OpenBSD.

Is this a bug?
Or why is this the expected behavior?

Regards,
Steffen (cpan: SULLR)


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