> Hi all,
>
> I am searching for a discussion of the pros/cons of using nohup
> instead of writing a daemon. While under Unix it is usual
> to write non-interactive programs as daemons, simply using
> nohup seems to have some advantages:
>
> - It requires less code.
> - It does not depend on system calls like setsid(),
> making the code more portable.
Most systems have the daemon() library function to take care of all
the details.
> - If the programs runs in the foreground by default, that makes
> debugging easier.
Adding a command line flag to run in the foreground is usually a
simple matter.
> So I wonder if there are advantages of coding a daemon which
> make it superior over nohup.
>
> While the primary purpose of nohup seems to be being used
> for scripts, and most server programs under unix are daemons,
> there are exceptions (AFAIK PostgreSQL postmaster).
> So I wonder if writing a daemon is worth the effort.
It all depends on what your program is supposed to do. Are you
writing something specific? Tell us a bit more, and we might be able
to advise you better.
--
Måns Rullgård
m...@inprovide.com
I am searching for a discussion of the pros/cons of using nohup
instead of writing a daemon. While under Unix it is usual
to write non-interactive programs as daemons, simply using
nohup seems to have some advantages:
- It requires less code.
- It does not depend on system calls like setsid(),
making the code more portable.
- If the programs runs in the foreground by default, that makes
debugging easier.
So I wonder if there are advantages of coding a daemon which
make it superior over nohup.
While the primary purpose of nohup seems to be being used
for scripts, and most server programs under unix are daemons,
there are exceptions (AFAIK PostgreSQL postmaster).
So I wonder if writing a daemon is worth the effort.
--
René Hartmann
> I am searching for a discussion of the pros/cons of using nohup
> instead of writing a daemon.
The most important advantage of not having a program fork() to put
itself in the background is that the user can decide whether the
program should be running in the background or not.
Of course, nohup is not the right way to start a daemon. Dan
Bernstein's "supervise" (from daemontools) is one of the best tools
for that job.
Take care,
--
Stefaan
--
As complexity rises, precise statements lose meaning,
and meaningful statements lose precision. -- Lotfi Zadeh