Web Hosting Talk







View Full Version : Signal Handling


Angelo
12-02-2006, 06:01 AM
Hello,

This may seem different from a php approach however i am trying to write a server in PHP. I have written a very simple socket server, which reads input from keyboard and writes the same to you back.

My server is working fine with child processes. However if anyone quits the server, that child process becomes defunct. I added signal handling but i seem unable to receive any signals on the server. posix_kill , or direct kill -9 through command line does not work for the childs too.

If anyone here knows signal handling on unix, i would like to share the piece of code i wrote, and you can help me before there is no hair left on my head.

http://pastey.net/2899

MrMan
12-02-2006, 09:52 AM
It's been a while since I did any signal handling in UNIX. In your code you need to catch the SIGKILL signal and assign that to your handler.

Angelo
12-02-2006, 04:51 PM
I though SIGCHLD would be better in my option however my code is just an example there, i have added all the signals and assigned them, does not differ.

I just wrote a smaller version of script to the paste bin:)