perl - Name of signal number 2 -
i wondered if there module or pragma defines names signal numbers returned system
call? example:
use feature qw(say); use strict; use warnings; $cmd = 'sleep 10'; $res = system $cmd; $signal = $res & 127; if ( $res == -1 ) { die "failed execute: $!\n"; } elsif ( $signal == 2 ) { " aborted user."; } elsif ( $signal ) { printf " command '%s' died signal %d, %s coredump.\n", $cmd, $signal, ( $? & 128 ) ? 'with' : 'without'; }
instead of $signal == 2
, think code maintenance, better use $signal == sig_abrt
..
yes, defined in posix
module:
% perl -e 'use posix; printf "%s\n", sigabrt;' 6
Comments
Post a Comment