discuss: Linux Daemon HOWTO


Previous by date: 19 May 2004 16:37:20 -0000 Re: How the LDP works . . . ., Martin A. Brown
Next by date: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Devin Watson
Previous in thread: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Charles Curley
Next in thread: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Devin Watson

Subject: Re: Linux Daemon HOWTO
From: Colin Watson ####@####.####
Date: 19 May 2004 16:37:20 -0000
Message-Id: <20040519163705.GA19408@riva.ucam.org>

On Tue, May 18, 2004 at 05:45:34PM -0600, Charles Curley wrote:
>         /* Change the current working directory */
>         if ((chdir("/")) < 0) {
>    		/* Log failure, then close logs */
> 
> 
> 		exit(EXIT_FAILURE);
>         }
> 
> You should probably log the failure so that the user knows she doesn't
> have a necessary directory. In that case, if you are handling your
> log files yourself, you have to close them gracefully before you exit
> so that the last few entries are preserved.
> 
> Also, I doubt you want a daemon to run in /.

You generally do want daemons to chdir("/") before doing anything else.
That way, they don't (for example) stop /home from being unmounted if
you happened to be standing in your home directory when you started the
daemon.

-- 
Colin Watson                                  ####@####.####

Previous by date: 19 May 2004 16:37:20 -0000 Re: How the LDP works . . . ., Martin A. Brown
Next by date: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Devin Watson
Previous in thread: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Charles Curley
Next in thread: 19 May 2004 16:37:20 -0000 Re: Linux Daemon HOWTO, Devin Watson


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.