tags:

views:

17

answers:

1

Hi all,

I just wrote php daemon for my app and want to implement some output information generated on specified signal (SIGUSR1). I got signal handler in code

    pcntl_signal(SIGUSR1, array($this, 'signal_status'));

and function handler prepared

  protected function signal_status($signal_number)
  { printf("blah\n"); }

Everything work except one thing. When i send signal to my daemon (posix_kill($pid, SIGUSR1) or even simple kill -10 pid in bash) i got output in console that starts daemon.

Is it possible to get file descriptor of caller and not of the daemon? I wan't to send this data to specified output (for example after kill -10 PID) and not into FD of daemon.

I hope i wrote this clearly :)

A: 

Well, you can not, sending a signal is just setting up some operating system primitives, it has nothing to do with setting up a communication path between your daemon on one hand and the tool used to generate the signal on the other hand. The alternatives you have are either watching the console output of the daemon, or making the daemon dump status to a logfile and create some sort of utility to send the signal and print the logfile (and if you're going that way, why not throw out the logfile altogether and setup a periodical dump of your logging anyhow, since signals are not a polite way of doing inteprocess communiation.

amo-ej1
well thats what i thought, just was currious if you can get somehow FD of "signal caller" and dump data directly to it (for example /dev/pts/7) - anyway thanks for the answer :)
tomaszsobczak
the clean solution would be to offer some real form of inter process communication to your daemon (think soap, think rpc, think listening on a socket, think using a pipe, ...) i don't think you can identify the origin of a signal
amo-ej1