From: Loic Dachary Date: Thu, 24 Nov 2016 18:52:14 +0000 (+0100) Subject: tests: facilitate background process debug in ceph-helpers.sh X-Git-Tag: v11.1.0~156^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f491ea062ddc651e69d49ebadd7a805bd9741d7e;p=ceph.git 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 --- diff --git a/qa/workunits/ceph-helpers.sh b/qa/workunits/ceph-helpers.sh index 4a61ef052d4..0535469b769 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+=\" $!\"" }