From 1098ec7b02bbfd71e0b84f79f86212173831652f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 20 Apr 2023 11:07:44 -0400 Subject: [PATCH] Tests: utils: lttng_pgrep spams output when racing with a process MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit lttng_pgrep is often used to check if a process is alive. As such, it is often used on PIDs which are tearing down. The file redirection used in `tr '\0' '\n' < /proc/"$pid"/cmdline` often fails (which is correct) because the /proc/$pid folder no longer exists. When this occurs, the test output is cluttered with annoying errors like: ./tests/regression/kernel//../../utils/utils.sh: line 151: /proc/845/cmdline: No such file or directory This part of the command now runs under a subshell to hide the error when it occurs. Signed-off-by: Jérémie Galarneau Change-Id: I6a26cb63cd56c46557a73e2e475b0cac729cc67f --- 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 9ffcc6ff2..3e1a81ce5 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -148,7 +148,7 @@ function lttng_pgrep () while IFS= read -r pid ; do # /proc/pid/cmdline is null separated. - if full_command_no_argument=$(tr '\0' '\n' < /proc/"$pid"/cmdline 2>/dev/null | head -n1); then + if full_command_no_argument=$( (tr '\0' '\n' < /proc/"$pid"/cmdline) 2>/dev/null | head -n1); then command_basename=$(basename "$full_command_no_argument") if grep -q "$pattern" <<< "$command_basename"; then echo "$pid" -- 2.34.1