[Pkg-privacy-commits] [Git][pkg-privacy-team/monkeysphere][master] tests/keytrans: Avoid hangs when run with subprocesses

Daniel Kahn Gillmor dkg at debian.org
Tue Mar 5 19:57:59 GMT 2019


Daniel Kahn Gillmor pushed to branch master at Privacy Maintainers / monkeysphere


Commits:
48785b0e by Daniel Kahn Gillmor at 2019-03-05T19:19:34Z
tests/keytrans: Avoid hangs when run with subprocesses

When bash 5.0 uses process replacement [0], the main process gets
invoked with child processes already present.

This wreaks havoc with our understanding of what "wait" does, and can
make the test suite hang (see https://bugs.debian.org/920038).  So we
introduce this check to make sure that there are no running
subprocesses.

This is particularly problematic because debian's autopkgtest *does*
invoke the test suite in this way.

Note that there might be some weird race condition here -- we allow
there to be 1 subprocess, which is the spawned "ps" program itself.
but how ps works on a given platform, and whether it will notice (and
count) itself, i don't know.  But it WorksForMeâ„¢ on debian buster.

[0] e.g., bash's process replacement looks like this:

    tests/keytrans > >(tee $TMPDIR/stdout)

- - - - -


1 changed file:

- tests/keytrans


Changes:

=====================================
tests/keytrans
=====================================
@@ -7,7 +7,7 @@
 #   Jameson Rollins <jrollins at fifthhorseman.net>
 #   Micah Anderson <micah at riseup.net> 
 #
-# Copyright: 2008-2009
+# Copyright: 2008-2019
 # License: GPL v3 or later
 
 # these tests should all be able to run as a non-privileged user.
@@ -17,6 +17,14 @@ set -e
 # piped commands should return the code of the first non-zero return
 set -o pipefail
 
+declare -a child_procs=($(ps -o pid h --ppid $$))
+if [ "${#child_procs[@]}" -gt 1 ]; then
+    printf 'found %d pre-existing child processes: %s\n' "${#child_procs[@]}" "${child_procs[*]}"
+    printf "spawning my own subprocess to avoid https://bugs.debian.org/920038...\n"
+    "$0" "$@"
+    exit
+fi
+
 # make sure the TESTDIR is an absolute path, not a relative one.
 export TESTDIR=$(cd $(dirname "$0") && pwd)
 



View it on GitLab: https://salsa.debian.org/pkg-privacy-team/monkeysphere/commit/48785b0e71407d5c45de89df024d1afce65454a6

-- 
View it on GitLab: https://salsa.debian.org/pkg-privacy-team/monkeysphere/commit/48785b0e71407d5c45de89df024d1afce65454a6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-privacy-commits/attachments/20190305/68f9c14b/attachment-0001.html>


More information about the Pkg-privacy-commits mailing list