0

This is a duplicate question from here: Differences in controlling daemons & applications only with updated tags so more people can view it and comment.


Hi everyone,

With respect to this excellent post:

What's the difference between nohup and a daemon?

I would like to ask the following:

After launching an application from my terminal, the application keeps running either in the background or the foreground and the only thing I can do to interact with it is by sending it signals from my terminal (given that stdin is still in place).

However, after a daemon process is launched, I realized that it can be controlled with other means like querying it or restarting it (arch way):

# /etc/rc.d/daemon-name {start|stop|restart|status|...}

Could someone explain to me if that feature is built-into the general "daemon framework" and applies to every daemon process as a special feature or is it just a provision that processes designed to run as a daemon will have to handle internally?

And to add more to the matter, how on earth are we able to "control" daemons from the terminal using their name (i.e. sambad stop) while applications always have to be referred using their name (i.e. kill -9 1234)?

Thank you in advance!


Community
  • 1
  • 1
stratis
  • 7,750
  • 13
  • 53
  • 94
  • Topic can be closed now. I was essentially looking on how inter process communication can be achieved since plain unix signals don't carry any information. – stratis Jul 30 '12 at 19:41

1 Answers1

1

This is done differently for different daemons. Just look into those files (/etc/rc.d/*) and see how it's done.

On debian most services use start-stop-daemon. PID is stored in a file and start-stop-daemon sends signals to that PID.

Piotr Praszmo
  • 17,928
  • 1
  • 57
  • 65
  • Even if the mapping is as you claim to be, these are much more than plain signals. status and other commands force the daemon to print information while it is already running(!!) when no application can handle flags after is launched..! – stratis Jul 28 '12 at 18:23
  • @Konos5 which daemons and which commands? There are many ways to achieve this. On my machine `status` just check if process is running. – Piotr Praszmo Jul 28 '12 at 19:01