title: RedHat daemon function usage
body: <p>I'm working on an init script for Jetty on RHEL. Trying to use the <code>daemon</code> function provided by the init library (<code>/etc/rc.d/init.d/functions</code>).</p>
  
  <p>I found <a href="http://www.sensi.org/~alec/unix/redhat/sysvinit.html">this terse documentation</a>, and <a href="http://bitten.edgewall.org/wiki/BittenSlaveDaemonRedhat">an online example</a> (I've also been looking at other init scripts on the system for examples).</p>
  
  <p>Look at this snippet from online to start the daemon</p>
  
  <pre><code>daemon --user="$DAEMON_USER" --pidfile="$PIDFILE" "$DAEMON $DAEMON_ARGS &amp;"
  RETVAL=$?
  pid=`ps -A | grep $NAME | cut -d" " -f2`
  pid=`echo $pid | cut -d" " -f2`
  if [ -n "$pid" ]; then
          echo $pid &gt; "$PIDFILE"
  fi
  </code></pre>
  
  <p>Why bother looking up the <code>$PID</code> and writing it to the <code>$PIDFILE</code> by hand? I guess I'm wondering what the point of the <code>--pidfile</code> option to the <code>daemon</code> function is.</p>