SIGALRM while sleeping on Solaris 9

In running Perl on a chroot environment on Solaris 9 (Sparc), I am launching a slightly strange error. We use custom Perl, but it is almost certainly Perl 5.8.7, and this version has been running for many years on various platforms, including Solaris 8-10.

The following code is pretty simple:

#!/usr/bin/perl
use strict; 
use warnings;

print "About to sleep(1)\n";
sleep 1;
print "Just woke up!\n";

However, if I ran this, "Just woke up!" never printed - instead, the program ends and the "Alarm" is displayed. This only happens if there is a dream - if I write a program that does a lot of math and takes 10 seconds, everything works fine. This also happens only in the chroot environment.

I dropped% SIG, which has an 'ALRM => undef' entry, which is expected to have a non-chrooted environment with the same behavior. However, if I modify the script to include:

$SIG{ALRM} = sub {};

... everything works perfectly. So what is this deal? I don't have much experience with Solaris, but there should be a way to get the default signal handlers to behave properly.

+3
source share
3 answers

The first thing I will try is to run the sample program under the farm:

truss testprogram.pl

This will show the actual system calls used to implement sleep. On a Solaris 8 system that I have access to, the corresponding part of the output is:

write(1, " A b o u t   t o   s l e".., 18)      = 18
time()                                          = 1247258429
alarm(0)                                        = 0
sigaction(SIGALRM, 0xFFBEF6E0, 0xFFBEF790)      = 0
sigfillset(0xFF0C28D0)                          = 0
sigprocmask(SIG_BLOCK, 0xFFBEF780, 0xFFBEF770)  = 0
alarm(1)                                        = 0
    Received signal #14, SIGALRM, in sigsuspend() [caught]
sigsuspend(0xFFBEF760)                          Err#4 EINTR
setcontext(0xFFBEF448)
alarm(0)                                        = 0
sigprocmask(SIG_UNBLOCK, 0xFFBEF780, 0x00000000) = 0
sigaction(SIGALRM, 0xFFBEF6E0, 0x00000000)      = 0
time()                                          = 1247258430
Just woke up!
write(1, " J u s t   w o k e   u p".., 14)      = 14

On a Solaris 10 host, it displays:

write(1, " A b o u t   t o   s l e".., 18)      = 18
time()                                          = 1247258270
nanosleep(0xFFBFF770, 0xFFBFF768)               = 0
time()                                          = 1247258271
Just woke up!
write(1, " J u s t   w o k e   u p".., 14)      = 14

, - Solaris 8, - , , sigaction().

, , chroot/usr/lib . , , - perl.

+3

sleep 1 select(undef, undef, undef, 1) .

, , , chroot'd perl script sleep SIGALRM ( POSIX), - perl , , , . perl? chroot'd libc? perl -e "sleep 1" chroot ? .. .. , .

, : select SIGALRM.

+9

Perl, Solaris? , . , Perl 5.8.7, , script .

script , , , Perl. script , Perl 5.8.9, , , . , , , Perl. , perlbug, .

+1

Source: https://habr.com/ru/post/1711891/


All Articles