[Top][All Lists]

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

Re: exit status issue

From: Dallas Clement
Subject: Re: exit status issue
Date: Wed, 23 Nov 2011 14:09:57 -0600

Hi All,

Just wanted to let you know that I have found a solution to my
problem, though I can't entirely explain it yet.  As mentioned
earlier, this script was designed to run as a daemon, i.e. run in the
background.  This is what I was doing to daemonize the script:

        while :
                sleep 1

trap CleanupExit INT
trap CleanupExit TERM
trap CleanupExit ILL
trap CleanupExit QUIT
trap CleanupExit ABRT
trap CleanupExit KILL

if [ x"$1" = x"start" ]; then
        Daemon 0<&- 1>/dev/null 2>&1 &
        echo $! > $PIDFILE
elif [ x"$1" = x"stop" ]; then
        TMP=`cat $PIDFILE`
        kill $TMP

When running like this, I was seeing 'touch' command failures inside
function fsaccesstest() shown previously.

I did an experiment last night and ran this script in the foreground
(removed the &) from the call to Daemon.  To my surprise, I did not
see any errors with the 'touch' command.

I then went back and changed how I was turning this script into a
daemon, by using the start-stop-daemon utility instead like this:

start-stop-daemon --start --background --quiet --exec $DAEMON

Once I did this, my shell script is now running in the background
without any errors.  Life is good.

Perhaps when I was calling Daemon & as shown above, the parent process
was not exiting properly and was somehow interfering in the child
process execution.  I'm not really sure.

Anyhow, I'm past this problem now.  Thank you all for the good ideas
and generous help.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]