开发者

Stop and start Unix daemon in C

开发者 https://www.devze.com 2023-03-20 18:04 出处:网络
I\'m trying to develop a daemon (unix plateforme) with this capabilities(command line): user@unixbox>myDaemon start // This start the daemon

I'm trying to develop a daemon (unix plateforme) with this capabilities(command line):

user@unixbox>myDaemon start // This start the daemon
user@unixbox>myDaemon stop // This stop the daemon
user@unixbox>myDaemon show // This will show so开发者_StackOverflow中文版me stuff that the daemon is doing

If you know any documentation or ideas on how this can be implemented. please let me know :).

Thanks.


This is usually done by delivering signals to the daemon process.

You have to choose a particular signal to respond to in your daemon (SIGTERM, SIGQUIT, SIGSTOP, etc.) by installing a handler that is invoked each time the process receives the signal.

From the shell you can send signals to a process using the kill(1) command.

Note that a graceful daemon stop may be quite tricky if you have active clients/connections/jobs. Normally you should stop receiving new ones and wait until the last one is finished.

0

精彩评论

暂无评论...
验证码 换一张
取 消