]> code.ossystems Code Review - openembedded-core.git/commitdiff
busybox: Improve syslog restart handling
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 26 Jun 2019 13:01:33 +0000 (14:01 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 27 Jun 2019 11:20:24 +0000 (12:20 +0100)
We're seeing races on the autobuilder where syslogd fails to shut down
fast enough to be restarted leading to failures.

Add some checks to ensure when restarting that processes exit before
being restarted.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/busybox/files/syslog

index 89c4d12e9cd56690e9b6cb9fe68f4f490dbc534a..49033c1755a532ba794573a79cb55eda70609bc9 100644 (file)
@@ -51,6 +51,22 @@ else
        SYSLOG_ARGS="-C"
 fi
 
+waitpid ()
+{
+  pid=$1
+  # Give pid a chance to exit before we restart with a 5s timeout in 1s intervals
+  if [ -z "$pid" ]; then
+    return
+  fi
+  timeout=5;
+  while [ $timeout -gt 0 ]
+  do
+    timeout=$(( $timeout-1 ))
+    kill -0 $pid 2> /dev/null || break
+    sleep 1
+  done
+}
+
 case "$1" in
   start)
        echo -n "Starting syslogd/klogd: "
@@ -65,7 +81,11 @@ case "$1" in
        echo "done"
        ;;
   restart)
-       $0 stop
+       pid1=`pidof syslogd`
+       pid2=`pidof syslogd`
+       $0 stop
+       waitpid $pid1
+       waitpid $pid2
        $0 start
        ;;
   *)