]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tests: facilitate background process debug in ceph-helpers.sh
authorLoic Dachary <ldachary@redhat.com>
Thu, 24 Nov 2016 18:52:14 +0000 (19:52 +0100)
committerLoic Dachary <ldachary@redhat.com>
Thu, 24 Nov 2016 18:52:14 +0000 (19:52 +0100)
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 <loic@dachary.org>
qa/workunits/ceph-helpers.sh

index 4a61ef052d456784d77968c2b3b7f72e467b48ae..0535469b769070a8ebfbb3c575b1e2dd7dbda0f8 100755 (executable)
@@ -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+=\" $!\""
 }