> -----Original Message-----
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 04, 2001 1:32 AM
> To: [EMAIL PROTECTED]
> Subject: Killing a deamon
>
>
> List,
>
> Is there a quiker way to restart a perl daemon in UNIX rather than
> having to do a kill -9 PID then start the service again using
> ./name_of_file.pl. Is there any easy way like restarting the httpd
> daemon service httpd restart?
(You should not use kill -9 to stop your daemons; write them to
catch SIGTERM and stop gracefully).
This capability has to be implemented in the daemon itself. Actually,
httpd restart doesn't truly restart the parent httpd process; it just
kills off all the children and restarts them. If you want to restart
your main daemon process, you need to do something like this:
Assume your daemon is running (call it A). Then the command
mydaemon restart
Should do the following:
1. Unix starts a second copy of mydaemon (call it B). mydaemon
looks at its command line args and finds that you are trying to
restart it.
2. B determines the PID of A. This can be done by having A write its
PID out to a file, etc.
3. B sends a SIGTERM to A. mydaemon needs to be written to catch
the SIGTERM and terminate quickly and gracefully.
4. B waits for A to stop. It cannot use wait() or waitpid(), since
A is not a child of B. So it uses kill 0 or some such.
5. B then becomes a daemon.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]