Writing a daemon that can be used with service ?



I'm confused...

This web site tell you how to write a daemon:
http://www.linuxprofilm.com/articles/linux-daemon-howto.html#s1

This looks like it produces a straight executable with an infinite while
loop. What it doesn't say is how to stop the daemon gracefully.

When I've used daemons in the past I started and stopped them using
'service' i.e.
# service smb start
# service httpd stop

How do I write the kind of daemon that is used with service ?

Thanks
dom


.



Relevant Pages

  • Re: newbie: need inspiration
    ... Such daemon should have some exit function. ... > Overloading a variable is when you give it more than one purpose. ... the variable value holds the users input while the variable ... Loop should end when user ...
    (comp.unix.shell)
  • Re: Writing a daemon that can be used with service ?
    ... This looks like it produces a straight executable with an infinite while ... What it doesn't say is how to stop the daemon gracefully. ... that everything up to the "while " loop is what you need to do to ... You /can/ use signals and a signal handler to set the value that the ...
    (comp.os.linux.development.apps)
  • Re: will sleep() *terminated* the program?
    ... > will the double while loop helps instead of the single while loop? ... I know this is odd indeed. ... > what about make the proxy program into a daemon process, ... Do you start your program in background and then exit the shell? ...
    (comp.unix.programmer)
  • pause() and raise()
    ... signal handlers ), enters a forloop and calls ... to the daemon to invoke code triggered by the reception of these 2 ... SIGUSR1 and SIGUSR2 to itself at a user defined interval, ... call raisefrom within the forloop containing the pause ...
    (comp.unix.programmer)
  • Re: Writing a daemon that can be used with service ?
    ... This looks like it produces a straight executable with an infinite while loop. ... What it doesn't say is how to stop the daemon gracefully. ... - the start/stop rc script, which is used to start/stop/check the daemon process. ...
    (comp.os.linux.development.apps)