Chaitanya Yanamadala <dr.virus.in...@gmail.com> wrote on 05/24/2010
03:51:56 PM:
> but i cannot able to understand it.
> i am not that much of an expert in LINUX..

Besides what Shlomi already posted to help you, let me go further into
detail on my anti-daemonize thing.

Traditionally, Unix services have brought themselves into background by
means of forking (plus some file descriptor stuff) and ending the actual
parent process. While this looks convenient at first sight, the concept is
utterly broken for several reasons.

One cannot get the PID of the newly forked process by easy methods. Thus,
daemons write out PID files where the current PID is stored. This can fail
for several reasons, e.g. a simple typo in the path, or the daemon not
being allowed to create the file at all due to permission issues. Second,
how does a daemon react if the PID file is already there? It has to assume
that either it is a stale PID, i.e. the daemon isn't running and for some
reason the file has been left over, or there is already an instance of the
service running. So checks and double-checks have to be performed. Third,
some daemons fail to write out a PID file, but run nevertheless. So there's
no way to actually tell from the init script whether the daemon is running
or not.

Next, the forking model means that the service is not monitored. It may
crash at any time and nobody notices. (But will leave the PID file behind,
of course).

Also, the forking means that there's no easy and reliable way for logging.
Syslog may have died or not be available in the first place. Creating its
own log files does not only mean that there has to be a logging process
re-invented over and over again, but also faces the same problems the PID
file thingy already does.

There's a lot of room for problems, and even more for programmer mistakes.
And that's why I recommended daemontools and others.

                  Eric

--
Eric MSP Veith <eric.ve...@de.ibm.com>
Hechtsheimer Str. 2
DE-55131 Mainz
Germany

IBM Deutschland GmbH
Vorsitzender des Aufsichtsrats: Erich Clementi
Geschäftsführung: Martin Jetter (Vorsitzender), Reinhard Reschke, Christoph
Grandpierre, Matthias Hartmann, Michael Diemer, Martina Koederitz
Sitz der Gesellschaft: Stuttgart
Registergericht: Amtsgericht Stuttgart, HRB 14562
WEEE-Reg.-Nr. DE 99369940


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to