logo       

Re: [Boston.pm] daemonizing a perl script: msg#00024

Subject: Re: [Boston.pm] daemonizing a perl script
On Sunday, Feb 19th 2006 at 23:31 -0800, quoth Ranga Nathan:

=>I have a perl script that is in the start-up. Currently the startup uses 
=>"nohup <myscript> &". But that causes the script to swap out when there is 
=>no activity for a while. I am thinking of using "damon" command to 
=>daemonize it.  The script simply tails xfer log and takes action on files 
=>being deposited. It is not a server.
=>
=>I would like to know the common and accepted practice. 
=>
=>Thanks

You might need a clarification of what steps a proper daemon needs to do 
to be a proper daemon.

1. You need to close all of your open file descriptors. This is needed 
because if the daemon is started from a terminal, then that process will 
not relinquish control from that terminal.

2. You need to do the double fork trick to end up as a child of init. 

3. You probably want to call setsid(2) and setpgrp(2) to ensure that you 
are the head of your own process group and session.

4. Set your signal handlers for SIGTTIN and SIGTTOU to ignore.

5+. There may be more but I can't remember them. :-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe