<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Daemonizing Processes</title>
	<atom:link href="http://ignore.tv/2008/10/16/daemonizing-processes/feed/" rel="self" type="application/rss+xml" />
	<link>http://ignore.tv/2008/10/16/daemonizing-processes/</link>
	<description>Living Without Privacy</description>
	<lastBuildDate>Sun, 15 Jan 2012 05:31:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: James Cape</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127765</link>
		<dc:creator>James Cape</dc:creator>
		<pubDate>Sat, 18 Oct 2008 01:30:43 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127765</guid>
		<description>Jeff:

Sorry, I see daemon(3) and go into &quot;library call, can&#039;t use&quot; mode. Rudd-O was referring to upstart.

Alastair:

Yeah, it doesn&#039;t actually daemonize the process for you, though:

&lt;code&gt;$nice /bin/bash -c &quot;$corelimit &gt;/dev/null 2&gt;&amp;1 ; $*&quot;&lt;/code&gt;

It just launches it after setting a bunch of things, then checks the return value and prints the &lt;code&gt;[OK]&lt;/code&gt;/&lt;code&gt;[FAILED]&lt;/code&gt; messages.</description>
		<content:encoded><![CDATA[<p>Jeff:</p>
<p>Sorry, I see daemon(3) and go into “library call, can’t use” mode. Rudd-O was referring to upstart.</p>
<p>Alastair:</p>
<p>Yeah, it doesn’t actually daemonize the process for you, though:</p>
<p><code>$nice /bin/bash -c "$corelimit >/dev/null 2>&#038;1 ; $*"</code></p>
<p>It just launches it after setting a bunch of things, then checks the return value and prints the <code>[OK]</code>/<code>[FAILED]</code> messages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alastair</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127730</link>
		<dc:creator>Alastair</dc:creator>
		<pubDate>Fri, 17 Oct 2008 15:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127730</guid>
		<description>Red Hat have long used a function in the /etc/init.d/functions script called daemon to daemonise processes.  It allows passing optional nice level, a pidfile to track the resulting pid and a user to run as.</description>
		<content:encoded><![CDATA[<p>Red Hat have long used a function in the /etc/init.d/functions script called daemon to daemonise processes.  It allows passing optional nice level, a pidfile to track the resulting pid and a user to run as.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Schroeder</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127729</link>
		<dc:creator>Jeff Schroeder</dc:creator>
		<pubDate>Fri, 17 Oct 2008 14:57:46 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127729</guid>
		<description>James,

I wasn&#039;t referring to upstart at all, I was referring to setsid. setsid is part of util-linux and installed by default on EVERY RHEL box.

Here is one of our internal dns servers in asia:
root@ns1.tyo01.mtt:~ # cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5 (Tikanga)
root@ns1.tyo01.mtt:~ # rpm -qf `which setsid`
util-linux-2.13-0.44.el5
root@ns1.tyo01.mtt:~ # setsid
usage: setsid program [arg ...]

Also, disown requires you to background the process. Something like:
./somecommand &amp; disown -h

Note the -h to disown, that keeps it from dying in the event of a sighup.</description>
		<content:encoded><![CDATA[<p>James,</p>
<p>I wasn’t referring to upstart at all, I was referring to setsid. setsid is part of util-linux and installed by default on EVERY RHEL box.</p>
<p>Here is one of our internal dns servers in asia:<br />
<a href="mailto:root@ns1.tyo01.mtt">root@ns1.tyo01.mtt</a>:~ # cat /etc/redhat-release<br />
Red Hat Enterprise Linux Server release 5 (Tikanga)<br />
<a href="mailto:root@ns1.tyo01.mtt">root@ns1.tyo01.mtt</a>:~ # rpm –qf ‘which setsid‘<br />
util-linux-2.13–0.44.el5<br />
<a href="mailto:root@ns1.tyo01.mtt">root@ns1.tyo01.mtt</a>:~ # setsid<br />
usage: setsid program [arg …]</p>
<p>Also, disown requires you to background the process. Something like:<br />
./somecommand &amp; disown –h</p>
<p>Note the –h to disown, that keeps it from dying in the event of a sighup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Cape</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127722</link>
		<dc:creator>James Cape</dc:creator>
		<pubDate>Fri, 17 Oct 2008 12:48:21 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127722</guid>
		<description>Rudd-O/Jeff Schroeder:

Unfortunately, my platform is RHEL5, so there&#039;s no upstart, and the app I&#039;m trying to deal with is Java, so I can&#039;t call daemon(3). 

Luke:

That&#039;s actually a better solution, I had heard that was only in ksh, but apparently that&#039;s not the case. Thanks for that.</description>
		<content:encoded><![CDATA[<p>Rudd-O/Jeff Schroeder:</p>
<p>Unfortunately, my platform is RHEL5, so there’s no upstart, and the app I’m trying to deal with is Java, so I can’t call daemon(3). </p>
<p>Luke:</p>
<p>That’s actually a better solution, I had heard that was only in ksh, but apparently that’s not the case. Thanks for that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Williamson</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127709</link>
		<dc:creator>Adam Williamson</dc:creator>
		<pubDate>Fri, 17 Oct 2008 09:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127709</guid>
		<description>As well as daemon(3) there&#039;s daemonize:

[root@lenovo VTK]# urpmq -i daemonize
Name        : daemonize
Version     : 1.5.2
Release     : 2mdv2009.0
Group       : System/Servers
Size        : 18177                        Architecture: i586
Source RPM  : daemonize-1.5.2-2mdv2009.0.src.rpm
URL         : http://www.clapper.org/software/daemonize/
Summary     : Run a command as a Unix daemon</description>
		<content:encoded><![CDATA[<p>As well as daemon(3) there’s daemonize:</p>
<p>[root@lenovo VTK]# urpmq –i daemonize<br />
Name        : daemonize<br />
Version     : 1.5.2<br />
Release     : 2mdv2009.0<br />
Group       : System/Servers<br />
Size        : 18177                        Architecture: i586<br />
Source RPM  : daemonize-1.5.2-2mdv2009.0.src.rpm<br />
URL         : <a href="http://www.clapper.org/software/daemonize/" rel="nofollow">http://www.clapper.org/software/daemonize/</a><br />
Summary     : Run a command as a Unix daemon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Götz Waschk</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127701</link>
		<dc:creator>Götz Waschk</dc:creator>
		<pubDate>Fri, 17 Oct 2008 06:24:26 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127701</guid>
		<description>There&#039;s also daemonize: http://www.clapper.org/software/daemonize/</description>
		<content:encoded><![CDATA[<p>There’s also daemonize: <a href="http://www.clapper.org/software/daemonize/" rel="nofollow">http://www.clapper.org/software/daemonize/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127693</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Fri, 17 Oct 2008 03:02:03 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127693</guid>
		<description>Don&#039;t forget about the &#039;disown&#039; bash builtin:

       disown [-ar] [-h] [jobspec ...]
              Without  options,  each  jobspec  is  removed  from the table of
              active jobs.  If the -h option is given,  each  jobspec  is  not
              removed from the table, but is marked so that SIGHUP is not sent
              to the job if the shell receives a SIGHUP.   If  no  jobspec  is
              present,  and  neither the -a nor the -r option is supplied, the
              current job is used.  If no jobspec is supplied, the  -a  option
              means  to  remove or mark all jobs; the -r option without a job-
              spec argument restricts operation to running jobs.   The  return
              value is 0 unless a jobspec does not specify a valid job.

In other words, after invoking disown, if you close the associated terminal it doesn&#039;t kill the job.</description>
		<content:encoded><![CDATA[<p>Don’t forget about the ‘disown’ bash builtin:</p>
<p>       disown [-ar] [-h] [jobspec …]<br />
              Without  options,  each  jobspec  is  removed  from the table of<br />
              active jobs.  If the –h option is given,  each  jobspec  is  not<br />
              removed from the table, but is marked so that SIGHUP is not sent<br />
              to the job if the shell receives a SIGHUP.   If  no  jobspec  is<br />
              present,  and  neither the –a nor the –r option is supplied, the<br />
              current job is used.  If no jobspec is supplied, the  –a  option<br />
              means  to  remove or mark all jobs; the –r option without a job–<br />
              spec argument restricts operation to running jobs.   The  return<br />
              value is 0 unless a jobspec does not specify a valid job.</p>
<p>In other words, after invoking disown, if you close the associated terminal it doesn’t kill the job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Schroeder</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127690</link>
		<dc:creator>Jeff Schroeder</dc:creator>
		<pubDate>Fri, 17 Oct 2008 02:43:32 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127690</guid>
		<description>Damn, Rudd-O beat me to it. Take a look at daemon(3). setsid it the easiest way to do what you want. It does everything you want.</description>
		<content:encoded><![CDATA[<p>Damn, Rudd-O beat me to it. Take a look at daemon(3). setsid it the easiest way to do what you want. It does everything you want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rudd-O</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127688</link>
		<dc:creator>Rudd-O</dc:creator>
		<pubDate>Fri, 17 Oct 2008 01:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127688</guid>
		<description>oh, look into upstart events, you no longer need to write daemons if you use them.</description>
		<content:encoded><![CDATA[<p>oh, look into upstart events, you no longer need to write daemons if you use them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rudd-O</title>
		<link>http://ignore.tv/2008/10/16/daemonizing-processes/comment-page-1/#comment-127687</link>
		<dc:creator>Rudd-O</dc:creator>
		<pubDate>Fri, 17 Oct 2008 01:42:10 +0000</pubDate>
		<guid isPermaLink="false">http://ignore-your.tv/?p=486#comment-127687</guid>
		<description>Closing stdin is not enough. There is the chdir / and the double fork t
plus setsid to set the daemonized process as session leader, otherwise some signals sent to the parent process reach the &quot;daemon&quot;. I dunno if start stop daemon implements all of this correctly, but your sh trick is doing it wrong.</description>
		<content:encoded><![CDATA[<p>Closing stdin is not enough. There is the chdir / and the double fork t<br />
plus setsid to set the daemonized process as session leader, otherwise some signals sent to the parent process reach the “daemon”. I dunno if start stop daemon implements all of this correctly, but your sh trick is doing it wrong.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

