check the processname before killing it

This commit is contained in:
Patrick Ulbrich
2012-12-26 18:16:28 +01:00
parent 4974901646
commit a344df49a7

12
mailnag
View File

@@ -7,11 +7,13 @@ mkdir --parents "$config_dir"
if [ -f "$config_dir/mailnag.pid" ]; then
pid=$(cat "$config_dir/mailnag.pid")
kill $pid 2> /dev/null
# wait until mailnag teminates and removes it's pid file
while ps -p $pid > /dev/null; do
sleep 1
done
if [ "`ps -p $pid -o comm=`" == "mailnag" ]; then
kill $pid 2> /dev/null
# wait until mailnag teminates and removes it's pid file
while ps -p $pid > /dev/null; do
sleep 1
done
fi
fi
rm --force "$config_dir/mailnag.log"