diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-06-24 16:41:45 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-06-27 12:20:24 +0100 |
commit | dc1fcb61f7d89cd066ace2edc143e7a2d329e033 (patch) | |
tree | 4c49b7b9bff4cc5c5c9149fbb998bbdab6ba1799 /meta | |
parent | dc73872b828ea271678fa624c15199364a5cba9e (diff) | |
download | openembedded-core-contrib-dc1fcb61f7d89cd066ace2edc143e7a2d329e033.tar.gz |
sysklogd: Fix init script races
In testing we're seeing sysklogd fail to restart klogd since the original
process hasn't stopped before the new one is started. This means a restart
can result in no process running which is clearly not desireable.
Add extra code to ensure this works correctly. Busybox start-stop-daemon
seems particularly open to this kind of issue, the dpkg version maybe
less so if timeout options are used (which we don't use).
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rwxr-xr-x | meta/recipes-extended/sysklogd/files/sysklogd | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/recipes-extended/sysklogd/files/sysklogd b/meta/recipes-extended/sysklogd/files/sysklogd index 258f882803..73424840ba 100755 --- a/meta/recipes-extended/sysklogd/files/sysklogd +++ b/meta/recipes-extended/sysklogd/files/sysklogd @@ -90,6 +90,22 @@ running() return 0 } +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) log_begin_msg "Starting system log daemon..." @@ -113,17 +129,23 @@ case "$1" in start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile_syslogd --name syslogd log_end_msg $? log_begin_msg "Reloading kernel log daemon..." + pid=`cat $pidfile_klogd 2> /dev/null` start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd + waitpid $pid start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD log_end_msg $? ;; restart) log_begin_msg "Restarting system log daemon..." + pid=`cat $pidfile_syslogd 2> /dev/null` start-stop-daemon --stop --retry 5 --quiet --pidfile $pidfile_syslogd --name syslogd + waitpid $pid start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD log_end_msg $? log_begin_msg "Reloading kernel log daemon..." + pid=`cat $pidfile_klogd 2> /dev/null` start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd + waitpid $pid start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD log_end_msg $? ;; |