projects
/
shutils.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
xsession-daemon: More robust proc detection
[shutils.git]
/
xsession-daemon
diff --git
a/xsession-daemon
b/xsession-daemon
index f7edb638380256dc39a0c4346b2d3bd315807a4c..247c9036d2d5de89d0642627a21aeb9c98f0f14b 100755
(executable)
--- a/
xsession-daemon
+++ b/
xsession-daemon
@@
-22,33
+22,29
@@
PIDDIR="${PIDFILE%/*}"
LOGDIR="${LOGFILE%/*}"
mkdir -p $PIDDIR
LOGDIR="${LOGFILE%/*}"
mkdir -p $PIDDIR
-if [ $? -ne 0 ];
-then
+if [ $? -ne 0 ]; then
echo "Session daemon PIDDIR not there: $PIDDIR" >&2
exit 2
fi
mkdir -p $LOGDIR
echo "Session daemon PIDDIR not there: $PIDDIR" >&2
exit 2
fi
mkdir -p $LOGDIR
-if [ $? -ne 0 ];
-then
+if [ $? -ne 0 ]; then
echo "Session daemon LOGDIR not there: $LOGDIR" >&2
exit 2
fi
echo "Session daemon LOGDIR not there: $LOGDIR" >&2
exit 2
fi
-if [ -e "$PIDFILE" ] ;
-then
- echo "Session daemon '$NAME' PIDFILE found: $PIDFILE"
- PID=`cat "$PIDFILE"`
+if [ -e "$PIDFILE" ] ; then
+ PID=`cat "$PIDFILE"`
echo "Session daemon '$NAME' PID found: $PID"
echo "Session daemon '$NAME' PID found: $PID"
+
+ if pgrep -F "$PIDFILE" "${NAME}" >/dev/null ; then
+ echo "Session daemon '$NAME' was already running with PID $PID" >&2
+ exit 3
+ fi
else
echo "Session daemon '$NAME' PIDFILE NOT found: $PIDFILE"
fi
else
echo "Session daemon '$NAME' PIDFILE NOT found: $PIDFILE"
fi
-if [ "$PID" ] && kill -0 "$PID" 2>/dev/null ;
-then
- echo "Session daemon '$NAME' was already running with PID $PID" >&2
- exit 3
-fi
echo "Session daemon running $COMMAND $* > $LOGFILE 2>&1"
$COMMAND $* > "$LOGFILE" 2>&1 &
echo "Session daemon running $COMMAND $* > $LOGFILE 2>&1"
$COMMAND $* > "$LOGFILE" 2>&1 &
@@
-56,8
+52,7
@@
PID=$!
ERR=$?
sleep 1
ERR=$?
sleep 1
-if [ "$PID" ] && [ $ERR == 0 ] && kill -0 "$PID" 2>/dev/null;
-then
+if [ "$PID" ] && [ $ERR == 0 ] && kill -0 "$PID" 2>/dev/null; then
echo -n $PID > "$PIDFILE"
echo "Session daemon '$NAME' started with PID $PID"
else
echo -n $PID > "$PIDFILE"
echo "Session daemon '$NAME' started with PID $PID"
else