linux - perl multiple sig handlers pointing to one subroutine -


i brand new perl , trying add functionality scripts catch both keyboard interrupts , term signals if thrown, issue os command handle. need issue same os command , sub in case no signals thrown , script executed (note end block). far can tell research , testing, have register signal handler each signal. in each case, need trigger same sub. possible in 1 $sig, or have register both, 1 each signal? here code.

sub issuekdestroy{     system("kdestroy -q");     exit(1); } $sig{int} = (\&issuekdestroy); $sig{term} = (\&issuekdestroy); end{     issuekdestroy(); } 

from testing, not work:

$sig{'int', 'term'} = (\&issuekdestroy); 

it not recognize int or term in above code. suggestions?

$sig{'int', 'term'} isn't mean; assign values both keys that, use hash slice (and provide 2 values):

@sig{'int', 'term'} = (\&issuekdestroy, \&issuekdestroy); 

with $ instead, invoking perl4 style multidimensional array emulation allowed multiple keys specified stored them in single hash, equivalent to:

$sig{ join $;, 'int', 'term' } 

where $; chr(0x1c) default.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -