mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
net/mwan3: remove pid file use pgrep to get pid
If mwan3track will not stop immediately after sending the kill signal, the clean_up handler will delete the pid file later while the new mwan3track is already running. This could result in a situation that mwan3track is running more then once because the old mwan3track service could not be killed, because the pid file is missing. Using pgrep to kill all mwan3track for the tracked interface and not using pid file should fix this issue. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
@@ -390,10 +390,7 @@ mwan3_track()
|
||||
}
|
||||
config_list_foreach $1 track_ip mwan3_list_track_ips
|
||||
|
||||
if [ -e /var/run/mwan3track-$1.pid ] ; then
|
||||
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
|
||||
fi
|
||||
|
||||
kill $(pgrep -f "mwan3track $1") &> /dev/null
|
||||
if [ -n "$track_ips" ]; then
|
||||
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track $1 $2 $track_ips &
|
||||
fi
|
||||
@@ -401,18 +398,13 @@ mwan3_track()
|
||||
|
||||
mwan3_track_signal()
|
||||
{
|
||||
local pid status
|
||||
local pid
|
||||
|
||||
if [ -f "/var/run/mwan3track-${1}.pid" ]; then
|
||||
pid="$(cat "/var/run/mwan3track-${1}.pid")"
|
||||
status="$(pgrep -f mwan3track | grep "${pid}")"
|
||||
if [ "${status}" != "" ]; then
|
||||
kill -USR1 "${pid}"
|
||||
else
|
||||
$LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}"
|
||||
fi
|
||||
pid="$(pgrep -f "mwan3track $1")"
|
||||
if [ "${pid}" != "" ]; then
|
||||
kill -USR1 "${pid}"
|
||||
else
|
||||
$LOG warn "Unable to find \"/var/run/mwan3track-${1}.pid\" file for mwan3track on interface $1"
|
||||
$LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user