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:36 +0100 |
commit | a06a47af305d44212c3aa1fb936cfdfe22848d20 (patch) | |
tree | d529aa3a4b059046ff5012be8d3ef81cf8202fc1 /meta | |
parent | 3e2ab10159afd5b65e1120f25a7c347ad80f5227 (diff) | |
download | poky-a06a47af305d44212c3aa1fb936cfdfe22848d20.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).
(From OE-Core rev: dc1fcb61f7d89cd066ace2edc143e7a2d329e033)
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() | |||
90 | return 0 | 90 | return 0 |
91 | } | 91 | } |
92 | 92 | ||
93 | waitpid () | ||
94 | { | ||
95 | pid=$1 | ||
96 | # Give pid a chance to exit before we restart with a 5s timeout in 1s intervals | ||
97 | if [ -z "$pid" ]; then | ||
98 | return | ||
99 | fi | ||
100 | timeout=5; | ||
101 | while [ $timeout -gt 0 ] | ||
102 | do | ||
103 | timeout=$(( $timeout-1 )) | ||
104 | kill -0 $pid 2> /dev/null || break | ||
105 | sleep 1 | ||
106 | done | ||
107 | } | ||
108 | |||
93 | case "$1" in | 109 | case "$1" in |
94 | start) | 110 | start) |
95 | log_begin_msg "Starting system log daemon..." | 111 | log_begin_msg "Starting system log daemon..." |
@@ -113,17 +129,23 @@ case "$1" in | |||
113 | start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile_syslogd --name syslogd | 129 | start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile_syslogd --name syslogd |
114 | log_end_msg $? | 130 | log_end_msg $? |
115 | log_begin_msg "Reloading kernel log daemon..." | 131 | log_begin_msg "Reloading kernel log daemon..." |
132 | pid=`cat $pidfile_klogd 2> /dev/null` | ||
116 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd | 133 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd |
134 | waitpid $pid | ||
117 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD | 135 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD |
118 | log_end_msg $? | 136 | log_end_msg $? |
119 | ;; | 137 | ;; |
120 | restart) | 138 | restart) |
121 | log_begin_msg "Restarting system log daemon..." | 139 | log_begin_msg "Restarting system log daemon..." |
140 | pid=`cat $pidfile_syslogd 2> /dev/null` | ||
122 | start-stop-daemon --stop --retry 5 --quiet --pidfile $pidfile_syslogd --name syslogd | 141 | start-stop-daemon --stop --retry 5 --quiet --pidfile $pidfile_syslogd --name syslogd |
142 | waitpid $pid | ||
123 | start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD | 143 | start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD |
124 | log_end_msg $? | 144 | log_end_msg $? |
125 | log_begin_msg "Reloading kernel log daemon..." | 145 | log_begin_msg "Reloading kernel log daemon..." |
146 | pid=`cat $pidfile_klogd 2> /dev/null` | ||
126 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd | 147 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd |
148 | waitpid $pid | ||
127 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD | 149 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD |
128 | log_end_msg $? | 150 | log_end_msg $? |
129 | ;; | 151 | ;; |