From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsGzg-0001XV-Oh for qemu-devel@nongnu.org; Fri, 30 Oct 2015 17:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsGzf-0003Th-SH for qemu-devel@nongnu.org; Fri, 30 Oct 2015 17:13:52 -0400 References: <9e4f958b3895b7259b98d845bb46f000ba362869.1446232490.git.jcody@redhat.com> From: Max Reitz Message-ID: <5633DD87.1090302@redhat.com> Date: Fri, 30 Oct 2015 22:13:43 +0100 MIME-Version: 1.0 In-Reply-To: <9e4f958b3895b7259b98d845bb46f000ba362869.1446232490.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WribwXnU8DqFlPEsJtIfKdln6oUsvTkqw" Subject: Re: [Qemu-devel] [PATCH v3 1/2] qemu-iotests: fix cleanup of background processes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WribwXnU8DqFlPEsJtIfKdln6oUsvTkqw Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 30.10.2015 20:25, Jeff Cody wrote: > Commit 934659c switched the iotests to run qemu and qemu-nbd from a bas= h > subshell, in order to catch segfaults. Unfortunately, this means the > process PID cannot be captured via '$!'. We stopped killing qemu and > qemu-nbd processes, leaving a lot of orphaned, running qemu processes > after executing iotests. >=20 > Since the process is using exec in the subshell, the PID is the > same as the subshell PID. >=20 > Track these PIDs for cleanup using pidfiles in the $TEST_DIR. Only > track the qemu PID, however, if requested - not all usage requires > killing the process. >=20 > Reported-by: John Snow > Signed-off-by: Jeff Cody > --- > tests/qemu-iotests/058 | 12 ++++++++---- > tests/qemu-iotests/common.config | 14 ++++++++++++-- > tests/qemu-iotests/common.qemu | 18 ++++++++++++------ > tests/qemu-iotests/common.rc | 8 +++++--- > 4 files changed, 37 insertions(+), 15 deletions(-) >=20 > diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058 > index f2bdd0b..63a6598 100755 > --- a/tests/qemu-iotests/058 > +++ b/tests/qemu-iotests/058 > @@ -32,11 +32,17 @@ status=3D1 # failure is the default! > =20 > nbd_unix_socket=3D$TEST_DIR/test_qemu_nbd_socket > nbd_snapshot_img=3D"nbd:unix:$nbd_unix_socket" > +rm -f "${TEST_DIR}/qemu-nbd.pid" > =20 > _cleanup_nbd() > { > - if [ -n "$NBD_SNAPSHOT_PID" ]; then > - kill "$NBD_SNAPSHOT_PID" > + local NBD_SNAPSHOT_PID > + if [ -f "${TEST_DIR}/qemu-nbd.pid" ]; then > + read NBD_SNAPSHOT_PID < "${TEST_DIR}/qemu-nbd.pid" > + rm -f "${TEST_DIR}/qemu-nbd.pid" > + if [ -n "$NBD_SNAPSHOT_PID" ]; then No, I won't complain about using ! -z "" elsewhere and -n "" here. :-) Reviewed-by: Max Reitz > + kill "$NBD_SNAPSHOT_PID" > + fi > fi > rm -f "$nbd_unix_socket" > } --WribwXnU8DqFlPEsJtIfKdln6oUsvTkqw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWM92HAAoJEDuxQgLoOKytW6IH/ioSgzuD0e4mw/j6eAvwjqAk tWRCe8iqOAGkNnMGDO+lg3NNDkrvGm2eRYgOgMLWa53wiRzAz3NUrrg7GbhAGQif QGi9UP2y77dtNYOd5YhednCF+baIqazcTGdUwYueG0d99gfrI7dAJ+85o3yfsriZ Oom8uQDv0qZ3LjuTQZ/U6ifFfDaFU3+fHllStnV4h16hktNGrApyKpySTL8DSb08 UfwEJ5NAsqesXZjhcS4h+znPFRk24itTPU/d4oRt6kfkZ7WOnCu97Fk2ZIZixbOf cChFlG/0bGv6lJ1iwt668zPkls/23nhnbSGmVQ9lXtR5cbZ1Y06eODmzT8PjLCA= =tG1h -----END PGP SIGNATURE----- --WribwXnU8DqFlPEsJtIfKdln6oUsvTkqw--