From e75481b2f5e848be6366d4aa0b1bf6a29479bcca Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sat, 9 May 2020 11:00:06 -0500 Subject: [PATCH] fix warning regarding null byte --- roles/restic/files/restic-job.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/roles/restic/files/restic-job.sh b/roles/restic/files/restic-job.sh index eef29d6..c757150 100755 --- a/roles/restic/files/restic-job.sh +++ b/roles/restic/files/restic-job.sh @@ -71,9 +71,12 @@ if [ -f "$LOCK" ]; then printf "removing orphaned lock, pid %d does not exist\n" "$pid" rm -f "$LOCK" else - if [[ -f "/proc/${pid}/cmdline" ]] && ! [[ $(cat "/proc/${pid}/cmdline") =~ $(basename "$0") ]]; then - printf "removing orphaned lock, pid %d belongs to another process\n" "$pid" - rm -f "$LOCK" + if [[ -f "/proc/${pid}/cmdline" ]]; then + cmdline=$(tr "\0" " " <"/proc/${pid}/cmdline") + if ! [[ $cmdline =~ $(basename "$0") ]]; then + printf "removing orphaned lock, pid %d belongs to another process\n" "$pid" + rm -f "$LOCK" + fi else KEEP_LOCK=1 error_exit "another job is running, pid=${pid}"