1#!/usr/bin/perl 2# Test that timeout handles blocked SIGALRM from its parent. 3 4# Copyright (C) 2013-2023 Free Software Foundation, Inc. 5 6# This program is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19use strict; 20 21(my $ME = $0) =~ s|.*/||; 22 23eval { require POSIX; }; 24$@ 25 and CuSkip::skip "$ME: this script requires Perl's POSIX module\n"; 26 27use POSIX qw(:signal_h); 28my $sigset = POSIX::SigSet->new(SIGALRM); # define the signals to block 29my $old_sigset = POSIX::SigSet->new; # where the old sigmask will be kept 30unless (defined sigprocmask(SIG_BLOCK, $sigset, $old_sigset)) { 31 CuSkip::skip "$ME: sigprocmask failed; skipped"; 32} 33 34my @Tests = 35 ( 36 # test-name, [option, option, ...] {OUT=>"expected-output"} 37 # 38 39 ['block-alrm', ".1 sleep 10", {EXIT => 124}], 40 ); 41 42my $save_temps = $ENV{DEBUG}; 43my $verbose = $ENV{VERBOSE}; 44 45my $prog = 'timeout'; 46my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); 47 48exit $fail; 49