Delievering signals to daemon process

R

rahul

Hello all

I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
The approach I am following is to write the PID of the running server
in a flat file when server starts. When it needs to be stopped,
kill(SIGUSR1, pid) is sent to the server. The signal handler closes
all the open sockets and exits.

Your suggestions and alternate ways to accomplish it are welcome.

Regards,
Rahul
 
R

Richard Bos

rahul said:
I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
Your suggestions and alternate ways to accomplish it are welcome.

My suggestion is to ask this in comp.unix.programmer, because this is a
rather system-specific thing to do, and they will probably tell you of a
doohicky in a Unix system library somewhere which will do precisely what
you want to do, but which is not ISO C.

Richard
 
W

Walter Roberson

Hello all

I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
The approach I am following is to write the PID of the running server
in a flat file when server starts. When it needs to be stopped,
kill(SIGUSR1, pid) is sent to the server. The signal handler closes
all the open sockets and exits.

kill() is not part of the standard C language. The only standard C
mechanism to send a signal is to use raise(), which only works
with respect to the current program. There is no standard C
mechanism to send a signal to another program.
Your suggestions and alternate ways to accomplish it are welcome.

You can write a file into a fixed location, and have the second
program check the file periodically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top