[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: XFS won't daemonize



On Thu, 6 Dec 2001, Prince Mathew Samuel wrote:

> Yes I am sure, it is XFS. I removed XFS from my
> startup script and tried starting it separately from
> command line. This too results in XFS not going to the
> background. Any ideas?

Hmm. What version of xfs do you have? Is your init script significantly
different from mine? (attached)

-- 
I've had a perfectly wonderful evening.  But this wasn't it.
                -- Groucho Marx
#!/bin/sh
# /etc/init.d/xfs: start or stop the X font server

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/X11/xfs
PIDFILE=/var/run/xfs.pid
UPGRADEFILE=/var/run/xfs.upgrade

test -x $DAEMON || exit 0

# If we upgraded the daemon, we can't use the --exec argument to
# start-stop-daemon since the inode will have changed.  The risk here is that
# in a situation where the daemon died, its pidfile was not cleaned up, and
# some other process is now running under that pid, start-stop-daemon will send
# signals to an innocent process.  However, this seems like a corner case.
# C'est la vie!
if [ -e $UPGRADEFILE ]; then
  SSD_ARGS="--pidfile $PIDFILE --startas $DAEMON"
else
  SSD_ARGS="--pidfile $PIDFILE --exec $DAEMON"
fi

stillrunning () {
  if [ "$DAEMON" = "$(cat /proc/$DAEMONPID/cmdline 2> /dev/null)" ]; then
    true
  else
    # if the daemon does not remove its own pidfile, we will
    rm -f $PIDFILE $UPGRADEFILE
    false
  fi;
}

case "$1" in
  start)
    echo -n "Starting X font server: xfs"
    start-stop-daemon --start --quiet $SSD_ARGS -- -daemon || echo -n " already running"
    echo "."
  ;;

  restart)
    /etc/init.d/xfs stop
    if [ -f $PIDFILE ]; then
      if stillrunning; then
        exit 1
      fi
    fi
    /etc/init.d/xfs start
  ;;

  reload)
    echo -n "Reloading X font server configuration..."
    if start-stop-daemon --stop --signal 1 --quiet $SSD_ARGS; then
      echo "done."
    else
      echo "xfs not running."
    fi
  ;;

  force-reload)
    /etc/init.d/xfs reload
  ;;

  stop)
    echo -n "Stopping X font server: xfs"
    if [ ! -f $PIDFILE ]; then
      echo " not running ($PIDFILE not found)."
      exit 0
    else
      DAEMONPID=$(cat $PIDFILE | tr -d '[:blank:]')
      KILLCOUNT=1
      if [ ! -e $UPGRADEFILE ]; then
        start-stop-daemon --stop --quiet $SSD_ARGS || echo -n " not running"
      fi
      while [ $KILLCOUNT -le 5 ]; do
        if stillrunning; then
          kill $DAEMONPID
        else
          break
        fi
        sleep 1
        KILLCOUNT=$(expr $KILLCOUNT + 1)
      done
      if stillrunning; then
        echo -n "not responding to TERM signal (pid $DAEMONPID)"
      else
        rm -f $UPGRADEFILE
      fi
    fi
    echo "."
  ;;

  *)
    echo "Usage: /etc/init.d/xfs {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0

# vim:set ai et sts=2 sw=2 tw=0:

Reply to: