<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Python: Tips For Writing Daemons</title>
	<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/</link>
	<description>On Databases, Recovery, Tech</description>
	<pubDate>Mon, 06 Oct 2008 14:45:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Ben Finney</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-1013</link>
		<author>Ben Finney</author>
		<pubDate>Fri, 26 Sep 2008 05:41:32 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-1013</guid>
		<description>Other problems not dealt with:

* Dropping setuid and setgid privileges

* PID file handling: don't start if the PID file already exists, otherwise write the PID line to the specified file, remove the PID file when program terminates

* Signal handling: make sure cleanup is done in response to appropriate signals

Optional extras usually present in well-behaved daemons:

* Redirect stdout and stderr to syslog

* Drop root privileges and switch to a specified user and group id

* Operate within a chroot jail

* Respawn on termination

* Cooperate with operation under initd or inetd

I'm rather disappointed that these widely-standardised daemon behaviours aren't present in the Python standard library.</description>
		<content:encoded><![CDATA[<p>Other problems not dealt with:</p>
<p>* Dropping setuid and setgid privileges</p>
<p>* PID file handling: don&#8217;t start if the PID file already exists, otherwise write the PID line to the specified file, remove the PID file when program terminates</p>
<p>* Signal handling: make sure cleanup is done in response to appropriate signals</p>
<p>Optional extras usually present in well-behaved daemons:</p>
<p>* Redirect stdout and stderr to syslog</p>
<p>* Drop root privileges and switch to a specified user and group id</p>
<p>* Operate within a chroot jail</p>
<p>* Respawn on termination</p>
<p>* Cooperate with operation under initd or inetd</p>
<p>I&#8217;m rather disappointed that these widely-standardised daemon behaviours aren&#8217;t present in the Python standard library.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tips</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-468</link>
		<author>tips</author>
		<pubDate>Thu, 05 Jun 2008 10:31:20 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-468</guid>
		<description>&lt;strong&gt;tips...&lt;/strong&gt;

Good websites are few and far between; yours is a pleasure to visit; bookmarking for future visits and I enthusiastically recommend the same!...</description>
		<content:encoded><![CDATA[<p><strong>tips&#8230;</strong></p>
<p>Good websites are few and far between; yours is a pleasure to visit; bookmarking for future visits and I enthusiastically recommend the same!&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: warpedvisions.org &#187; Blog Archive &#187; HOWTO: Write daemons in Python</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-386</link>
		<author>warpedvisions.org &#187; Blog Archive &#187; HOWTO: Write daemons in Python</author>
		<pubDate>Mon, 05 May 2008 15:01:28 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-386</guid>
		<description>[...] 5th, 2008 in Links A few good tips on writing daemons in Python, including a Python example of the double-fork console detachment [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] 5th, 2008 in Links A few good tips on writing daemons in Python, including a Python example of the double-fork console detachment [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Wimer</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-385</link>
		<author>Scott Wimer</author>
		<pubDate>Mon, 05 May 2008 12:21:03 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-385</guid>
		<description>There are a few other steps in turning a process into a well behaved daemon.  Here are the steps I go through:

1. Fork   # Make new process 1
1.parent. Exit
1.child. Decouple from parent
  os.chdir("/")  # So we don't tie up a file system
  os.setsid()    # Become a session/group leader
  os.umask(0) # Could be other things here as well -- allow core's and what not.
1.child. Fork   # Make new process 2
2.parent. Exit
2.child Close all open file descriptors in a pinch, these are 0-1023
2.child Open stdin, stdout and stderr to /dev/null use os.dup2() for this if you want.
2.child Congrats, you're now a daemon. :)</description>
		<content:encoded><![CDATA[<p>There are a few other steps in turning a process into a well behaved daemon.  Here are the steps I go through:</p>
<p>1. Fork   # Make new process 1<br />
1.parent. Exit<br />
1.child. Decouple from parent<br />
  os.chdir(&#8221;/&#8221;)  # So we don&#8217;t tie up a file system<br />
  os.setsid()    # Become a session/group leader<br />
  os.umask(0) # Could be other things here as well &#8212; allow core&#8217;s and what not.<br />
1.child. Fork   # Make new process 2<br />
2.parent. Exit<br />
2.child Close all open file descriptors in a pinch, these are 0-1023<br />
2.child Open stdin, stdout and stderr to /dev/null use os.dup2() for this if you want.<br />
2.child Congrats, you&#8217;re now a daemon. <img src='http://blog.charcoalphile.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-381</link>
		<author>admin</author>
		<pubDate>Sun, 04 May 2008 18:42:55 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-381</guid>
		<description>Very true. os.dup2() is your friend.</description>
		<content:encoded><![CDATA[<p>Very true. os.dup2() is your friend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: just a foo</title>
		<link>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-377</link>
		<author>just a foo</author>
		<pubDate>Sun, 04 May 2008 11:00:01 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/05/03/python-tips-for-writing-daemons/#comment-377</guid>
		<description>Most UNIX daemons will also want to set an umask, chdir to some sensible directory and re-open stdin, stdout and stderr</description>
		<content:encoded><![CDATA[<p>Most UNIX daemons will also want to set an umask, chdir to some sensible directory and re-open stdin, stdout and stderr</p>
]]></content:encoded>
	</item>
</channel>
</rss>
