Skip to content

Commit cd2a243

Browse files
fix checking of running pid
When pgrep lists multiple pids, the check for a pid fails. So use the same logic as for NETBSD, with some flags of ps adapted because they mean something different.
1 parent ae564af commit cd2a243

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

rsync_tmbackup.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,17 @@ if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
370370
fn_log_error "Previous backup task is still active - aborting (command: $RUNNINGCMD)."
371371
exit 1
372372
fi
373-
elif [[ "$OSTYPE" == "netbsd"* ]]; then
373+
else
374+
PSFLAGS=''
375+
if [[ "$OSTYPE" == "netbsd"* ]]; then
376+
PSFLAGS=ax
377+
fi
378+
374379
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
375-
if ps -axp "$RUNNINGPID" -o "command" | grep "$APPNAME" > /dev/null; then
380+
if ps -${PSFLAGS}p "$RUNNINGPID" -o "command" | grep "$APPNAME" > /dev/null; then
376381
fn_log_error "Previous backup task is still active - aborting."
377382
exit 1
378383
fi
379-
else
380-
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
381-
if [ "$RUNNINGPID" = "$(pgrep -o -f "$APPNAME")" ]; then
382-
fn_log_error "Previous backup task is still active - aborting."
383-
exit 1
384-
fi
385384
fi
386385

387386
if [ -n "$PREVIOUS_DEST" ]; then

0 commit comments

Comments
 (0)