Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Perlでキーボード割り込みをキャッチするにはどうすればよいですか?
while(1) { try { print 1; } catch KeyboardInterrupt { print 2; } }
ここでPythonを作成しようとしているようです。
「キーボード割り込み」は、おそらくを意味しSIGINTます。%SIGハッシュを使用してシグナルを処理できます。例えば:
SIGINT
%SIG
$SIG{INT} = sub { print "Received SIGINT\n" };