terry has asked for the wisdom of the Perl Monks concerning the following question:

I know I can set $SIG{signal} to trap a signal, but I need something beyond this. I'm writing a daemon. When it recieves a kill -HUP it will reload the config file. Is there a way I can find out which tty the signal came from and send a message such as: "$0: configuration reloaded, continuing"
  • Comment on Sending output to the signalling terminal

Replies are listed 'Best First'.
RE: Sending output to the signalling terminal
by Anonymous Monk on Mar 08, 2000 at 00:08 UTC
    I've never heard of any method for a signalled process to find out what process sent the signal; I don't think it's possible. Most daemons would just write these messages to their logfile; httpd and named are examples. If your process really wants to write to a terminal, perhaps it shouldn't be a daemon.
Re: Sending output to the signalling terminal
by Anonymous Monk on Mar 08, 2000 at 21:13 UTC
    The receiving process has to know what the uid of the signalling pid is. In C, I think you use siginfo_t to find out info on the signalling pid. I dunno if that maps over to perl or not, tho. Good luck, sorry I couldn't be of more help, -- blue
Re: Sending output to the signalling terminal
by mortis (Pilgrim) on Mar 10, 2000 at 00:50 UTC
    Try looking into the POSIX module if you're on a system that supports POSIX (probably unix specific) and look into the C sigaction function for your system (as suggested by blue). The docs I have on the POSIX perl module says that it supports sigaction. I've never used it, but it's documented to be there... mortis
Re: Sending output to the signalling terminal
by Anonymous Monk on Mar 10, 2000 at 02:13 UTC
    The availability of this information depends on the platform. A quick look on a BSDi machine and a linux machine didn't reveal the siginfo_t support... Stevens "Advanced Programming in the UNIX Environment" implies that this is a SVR4 feature.