Re: How to "deamonize" ?

From: Pete Brett (pbrett_at_quaNlOitrSoPlAcMorp.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 08:46:23 GMT


"Martin Blume" <mblume@socha.net> wrote:

>"Franki" schrieb
>>
>> (running config : slackware with a 2.4.26 kernel )
>> I have a http server which run normally (a fork which accept
>> connections) . But I would like
>> to change the behaviour of my server (I would like to
>> daemonize it ) :
>
>man daemon

daemon() is not always available... and in any case, it gives less control.

If you just want to run in the background, you can fork() and have the parent
exit. The example code shown in Stevens does various other things like closing
stdin, stdout and stderror, chdir to "/" and ensuring that the daemon process is
not associated with a process group which could receive a HUP signal on modem
hangup etc.

Pete



Relevant Pages

  • Re: Problem with Daemon written in ruby...
    ... I don't see why having used fork should have affected ... Also, if your process needs to be a daemon, that should be the first thing you ... you'll find that you can't umount the file system the daemon ... Rick Nooner ...
    (comp.lang.ruby)
  • Re: Socket inheritance: A tale of two vendors
    ... > David Schwartz wrote: ... > The fork and exec are in B's libraries. ... Then the fault is in the daemon. ...
    (comp.unix.programmer)
  • Re: creating a daemon?
    ... Yeah ok, "FORK" being the golden word I failed to see at first, got some ... > can then be left running to do the daemon work. ... Once you have a working daemon, you need a way to start and stop ...
    (comp.lang.python)
  • Re: [autofs] automount does not close file descriptors at start
    ... >> This is the first time I've heard this and the first time I wrote a Unix ... >> daemon was fifteen years ago. ... I don`t do a double fork in autofs, although, long ago I ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Daemons in Linux
    ... Dieter Lunn wrote: ... Now which would be easier using fork(), threads, ... * int daemonise() ... * and turns it into a daemon using setsid. ...
    (comp.unix.programmer)