diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-15 22:34:50 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-15 22:37:17 +0100 |
commit | 7aa59c430eedbd2ac0f6ca5a5b87aa6052e8d233 (patch) | |
tree | e4cf2a5d1e396f980b5a6331989689b8221cf3ee | |
parent | 35ff59937b441bd0e4a1a24c34ad5bd81123404a (diff) |
gsmd: Work on stopping the respawn script and children
This is using some brute force. Make the shell script write a PID
file and on stop kill the respawn script and then all process names
that are spawned. For the stop we need to know that this is a bash
script.
-rw-r--r-- | recipes-openmoko/openmoko-gsmd/files/cell-log | 6 | ||||
-rw-r--r-- | recipes-openmoko/openmoko-gsmd/files/gsmd | 6 | ||||
-rw-r--r-- | recipes-openmoko/openmoko-gsmd/files/gsmd-respawn.sh | 7 |
3 files changed, 15 insertions, 4 deletions
diff --git a/recipes-openmoko/openmoko-gsmd/files/cell-log b/recipes-openmoko/openmoko-gsmd/files/cell-log index 0da23a6..74c1d68 100644 --- a/recipes-openmoko/openmoko-gsmd/files/cell-log +++ b/recipes-openmoko/openmoko-gsmd/files/cell-log @@ -7,11 +7,13 @@ # processname: cell_log PATH=/bin:/usr/bin:/sbin:/usr/sbin +PIDFILE=/var/run/cell_log.pid case "$1" in start) echo -n "Starting cell-log: " - start-stop-daemon -S -b -x /etc/gsmd-respawn.sh /usr/bin/cell_log + start-stop-daemon -S -b -p $PIDFILE \ + -x /etc/gsmd-respawn.sh /usr/bin/cell_log if [ $? = 0 ]; then echo "cell-log" @@ -21,7 +23,7 @@ case "$1" in ;; stop) echo -n "Stopping GSM daemon: " - start-stop-daemon -K -x /usr/bin/cell_log + start-stop-daemon -K -x bash -p $PIDFILE echo "cell-log." ;; restart|force-reload) diff --git a/recipes-openmoko/openmoko-gsmd/files/gsmd b/recipes-openmoko/openmoko-gsmd/files/gsmd index c135e1f..3501716 100644 --- a/recipes-openmoko/openmoko-gsmd/files/gsmd +++ b/recipes-openmoko/openmoko-gsmd/files/gsmd @@ -7,6 +7,7 @@ # processname: gsmd PATH=/bin:/usr/bin:/sbin:/usr/sbin +PIDFILE=/var/run/gsmd.pid [ -f /etc/default/rcS ] && . /etc/default/rcS [ -f /etc/default/gsmd ] && . /etc/default/gsmd @@ -19,7 +20,8 @@ case "$1" in [ -n "$GSM_RES" ] && ( echo "0" >$GSM_RES; sleep 2 ) echo -n "Starting GSM daemon: " - start-stop-daemon -S -b -x /etc/gsmd-respawn.sh /usr/sbin/gsmd -- gsmd -p $GSM_DEV $GSMD_OPTS -l syslog + start-stop-daemon -S -p $PIDFILE -b \ + -x /etc/gsmd-respawn.sh /usr/sbin/gsmd -- gsmd -p $GSM_DEV $GSMD_OPTS -l syslog if [ $? = 0 ]; then echo "gsmd." @@ -31,7 +33,7 @@ case "$1" in [ -n "$GSM_POW" ] && echo "0" >$GSM_POW echo -n "Stopping GSM daemon: " - start-stop-daemon -K -x /usr/sbin/gsmd + start-stop-daemon -K -x bash -p $PIDFILE echo "gsmd." ;; restart|force-reload) diff --git a/recipes-openmoko/openmoko-gsmd/files/gsmd-respawn.sh b/recipes-openmoko/openmoko-gsmd/files/gsmd-respawn.sh index d85dbb2..3714d2e 100644 --- a/recipes-openmoko/openmoko-gsmd/files/gsmd-respawn.sh +++ b/recipes-openmoko/openmoko-gsmd/files/gsmd-respawn.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash +NAME=`basename $1` +PIDFILE="/var/run/$NAME.pid" +PID=$$ +echo "$PID" > $PIDFILE + +trap "{ rm -f $PIDFILE ; killall -9 $NAME; }" EXIT + while true; do echo "Restarting not dealing well with spaces.." |