Skip to contentSkip to conversation

trousers: make initscript more reliable

PATCH New André Draszik 1 participant 1 message Nov 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trousers: make initscript more reliable

From: André Draszik <[email protected]>

The combination of using start-stop-daemon and pidof is not working reliably in all cases. Sometimes, the tcsd daemon isn't running yet at the time pidof is being invoked.

This results in an empty /var/run/tcsd.pid, making it impossible to stop tcsd using the init script.

To solve this, one could either add a delay before calling pidof, or alternatively use start-stop-daemon's built-in functionality to achieve the same.

Let's do the latter.

---
 meta-tpm/recipes-tpm/trousers/files/trousers.init.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta-tpm/recipes-tpm/trousers/files/trousers.init.sh +4 -2
index 0ecf7cc..d0d6cb3 100644
@@ -33,10 +33,12 @@ case "${1}" in
 			exit 0
 		fi
 
-		start-stop-daemon --start --quiet --oknodo --pidfile /var/run/${NAME}.pid --user ${USER} --chuid ${USER} --exec ${DAEMON} -- ${DAEMON_OPTS}
+		start-stop-daemon --start --quiet --oknodo \
+			--pidfile /var/run/${NAME}.pid --make-pidfile --background \
+			--user ${USER} --chuid ${USER} \
+			--exec ${DAEMON} -- ${DAEMON_OPTS} --foreground
 		RETVAL="$?"
 		echo "$NAME."
-		[ "$RETVAL" = 0 ] && pidof $DAEMON > /var/run/${NAME}.pid
 		exit $RETVAL
 		;;
 
Signature · 1 line
2.15.0.rc1