<?xml version="1.0" encoding="windows-1252"?>
<node id="838124" title="Re^3: How to capture system return code when command launched in the background?" created="2010-05-03 10:53:49" updated="2010-05-03 10:53:49">
<type id="11">
note</type>
<author id="747201">
afoken</author>
<data>
<field name="doctext">
&lt;p&gt;I think that djb's [http://cr.yp.to/daemontools.html|daemontools] could really help you here. Let daemontools handle the java process. The daemontools will take care of starting and restarting the java process, and they will also take care of reliable logging and safe log rotation. Daemontools have a reliable way to find out if a daemon is running or not (svok for programs, svstat for humans). Daemontools have a reliable way of controlling a daemon (svc). So all you need to do is to invoke svok and perhaps svc. You don't even have to check if the daemon is already running, &lt;c&gt;svc -u /service/java-daemon&lt;/c&gt; does nothing if the java daemon is already running.&lt;/p&gt;
&lt;p&gt;You could also consider using the inotify / dnotify API instead of scanning for files, and have your Perl script wait for any output of the java process. Your perl script could perhaps also run as a daemon under control of daemontools. You would get automatic restarts and logging for free ...&lt;/p&gt;
&lt;p&gt;Alexander&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-747201"&gt;
--&lt;br&gt;
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
837986</field>
<field name="parent_node">
838052</field>
</data>
</node>
