From 00d1ff64c4c7a19cd9e8bd705d76c5834d6dd822 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 30 Nov 2020 13:54:14 -0500 Subject: [PATCH] test: utils: lttng_pgrep performs lookup on non-existing pid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Observed issue ============== # Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 20962 20963 ./tests/regression/tools/trigger/start-stop//../../../../utils/utils.sh: line 103: /proc/20963/cmdline: No such file or directory Cause ===== lttng_pgrep performs a two step search/validation for the pattern. Since lttng_pgrep is used during tear-down of process (staged termination signalling) a process returned by pgrep might exit before the second check. Solution ======== Simply silence the error. The code flow already acknowledges the possibility of failure here. Known drawbacks ========= None References ========== Fixes: #1292 Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I82cb9fd4754c10a5104af495a8a959f4fbd92664 --- tests/utils/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 574495704..31087877d 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -100,7 +100,7 @@ function lttng_pgrep () while IFS= read -r pid ; do # /proc/pid/cmdline is null separated. - if full_command_no_argument=$(cut -d '' -f 1 < /proc/"$pid"/cmdline); then + if full_command_no_argument=$(cut -d '' -f 1 2>/dev/null < /proc/"$pid"/cmdline); then command_basename=$(basename "$full_command_no_argument") if grep -q "$pattern" <<< "$command_basename"; then echo "$pid" -- 2.34.1