Created
September 1, 2014 07:38
-
-
Save furu/49bc5440fc6a260394e9 to your computer and use it in GitHub Desktop.
シグナルが送信された場合には、実行中の処理が終了して送信されたシグナルのハンドラを処理したあとにさっき終了した処理のあとの処理に戻る。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
use strict; | |
use warnings; | |
$SIG{'URG'} = sub { | |
print "Recieved URG signal\n"; | |
}; | |
print "hi\n"; | |
for (my $cnt = 0; $cnt < 5; $cnt++) { | |
print $cnt, "\n"; | |
# ここの sleep 中に SIGURG を受信すると sleep が終了して、 | |
# 上のシグナルハンドラの処理が終わると print "foo\n"; に続く | |
# 処理が実行される。 | |
sleep(10); | |
print "foo\n"; | |
sleep(10); | |
print "bar\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment