From f491ea062ddc651e69d49ebadd7a805bd9741d7e Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 24 Nov 2016 19:52:14 +0100 Subject: [PATCH] tests: facilitate background process debug in ceph-helpers.sh When displaying the output of a background process, do it on stderr so that it is not bufferized. Otherwise the output of the background process may be displayed after it completed. Prefix the output of a background process with the PID of the process known to the parent instead of the PID of the awk process processing the output. When wait_background loops, it will print the process on which it is waiting and it is confusing that they do not match with the PID prefixing the process output. Refs: http://tracker.ceph.com/issues/17830 Signed-off-by: Loic Dachary --- qa/workunits/ceph-helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/workunits/ceph-helpers.sh b/qa/workunits/ceph-helpers.sh index 4a61ef052d45..0535469b7690 100755 --- a/qa/workunits/ceph-helpers.sh +++ b/qa/workunits/ceph-helpers.sh @@ -1413,7 +1413,7 @@ function run_in_background() { shift; # Execute the command and prepend the output with its pid # We enforce to return the exit status of the command and not the awk one. - ("$@" |& awk '{ a[i++] = $0 }END{for (i = 0; i in a; ++i) { print PROCINFO["pid"] ": " a[i]} }'; return ${PIPESTATUS[0]}) & + ("$@" |& awk '{ a[i++] = $0 }END{for (i = 0; i in a; ++i) { print "'$$': " a[i]} }'; return ${PIPESTATUS[0]}) >&2 & eval "$pid_variable+=\" $!\"" } -- 2.47.3