In article <20**********************************@e4g2000hsg.g ooglegroups.com>,
rahul <ra*********@gmail.comwrote:
>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.
--
"There are some ideas so wrong that only a very intelligent person
could believe in them." -- George Orwell