[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: init.d startup script does not exit

On Sun, Sep 14, 2008 at 04:05:41AM -0300, Gabriel Parrondo wrote:

> Also, this thread deserves a loud WTF. I mean, the OP seems to know the
> basics about unix administration (he was able to write a shell script,
> at least) but fails at something as basic as running an app in
> background.

There's more to daemonizing than running an app in the background.

* You need to fork twice, so the process becomes son of init, and is not
  affected by the death of the parent shell.
* You need to detach it from the terminal: redirect stdin, stdout and
  stderr ftom/to /dev/null or a file.
* Furthermore, you need to make sure it closes all other file
  descriptors it it may have open.
* It needs to chdir to /, so it won't prevent you from unmounting a file
  system merely by its working directory.

The authors of proprietary program he intends to run probably deserve a
loud WTF if they have not prepared their program to daemonize.

Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend

Reply to: