#!/usr/bin/perl -w use strict; use POSIX (); my $sigset = POSIX::SigSet->new(POSIX::SIGHUP); $SIG{HUP}=\&cleanup; sub cleanup{ print "ALRM!\n"; } while (1){ sleep 1; } 

I launch the program and open another terminal, in which I find through ps auxww | grep s.pl ps auxww | grep s.pl s.pl script id

Further I do kill 1 12345 - I send a sighup signal sighup my script to see how the signal handler will work in it

and in the first terminal the process ends, although I have to write ALRM! in my wish ALRM! on stdout

what to do? how to be? who is guilty?

  • That's right, and write kill 1 12345 ? no sign - before 1? and how you just init and the whole system with it does not kill .... - Mike
  • yeah, on the production server, from under the root =) it was necessary to write kill -HUP 12345 =) it all worked =) - vilfred
  • just read somewhere that sighup has the number 1, that's why that one is vilfred
  • 2
    Well, yes, he is the first, only kill accepts either the name or number of the signal, but always with a minus to distinguish it from the pid. So kill -1 12345 similar to -HUP - Mike

1 answer 1

although my Wishlist should write ALRM! on stdout

I started your program and everything works fine.

 $ uname -a Linux kes-desktop 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 

What is your system ??

Print a list of all the signals that your system supports and the pearl can intercept them:

 local $, = "\n"; print sort keys %SIG; 
  • They wrote in the comments that the matter is in the missed hyphen before the signal number. - MAN69