From 9eeb500a922f3df831ec564a28262ec60e9a8d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Sun, 24 Jul 2016 17:45:14 +0200 Subject: Check if PIDs file exists --- backuper.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backuper.sh b/backuper.sh index 9324b0c..95e3c25 100644 --- a/backuper.sh +++ b/backuper.sh @@ -148,11 +148,13 @@ error_handler() { cleanup() { trap - EXIT INT QUIT TERM HUP ILL TRAP BUS FPE SEGV - for PID in $(cat "$RUNDIR"/"$PID_FILE"); do - if ps --ppid $$ | grep -q "$PID"; then - kill "$PID" - fi - done + if [ -f "$RUNDIR"/"$PID_FILE" ]; then + for PID in $(cat "$RUNDIR"/"$PID_FILE"); do + if ps --ppid $$ | grep -q "$PID"; then + kill "$PID" + fi + done + fi [ -n "$PID_GENERATE" ] && if ps --ppid $$ | grep -q "$PID_GENERATE"; then kill "$PID_GENERATE" -- cgit v1.2.3