Received: from eggs.gnu.org ([2001:4830:134:3::10]:37754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFhW5-0008JW-DR for qemu-devel@nongnu.org; Tue, 18 Feb 2014 05:03:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFhVz-00064k-Fg for qemu-devel@nongnu.org; Tue, 18 Feb 2014 05:03:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFhVz-00064d-6p for qemu-devel@nongnu.org; Tue, 18 Feb 2014 05:02:59 -0500 From: Markus Armbruster References: <1392651898-16749-1-git-send-email-stefanha@redhat.com> <1392651898-16749-4-git-send-email-stefanha@redhat.com> <878ut9u1k4.fsf@blackfin.pond.sub.org> Date: Tue, 18 Feb 2014 11:02:52 +0100 In-Reply-To: <878ut9u1k4.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Mon, 17 Feb 2014 17:49:31 +0100") Message-ID: <87sirgivqr.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/3] qtest: kill QEMU process on g_assert() failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Peter Maydell , qemu-devel@nongnu.org, Anthony Liguori , Andreas Faerber Markus Armbruster writes: > Stefan Hajnoczi writes: > >> The QEMU process stays running if the test case fails. This patch fixes >> the leak by installing a SIGABRT signal handler which invokes >> qtest_end(). >> >> In order to make that work for assertion failures during qtest_init(), >> we need to initialize QTestState fields including file descriptors and >> pids carefully. qtest_quit() is then safe to call even during >> qtest_init(). >> >> Signed-off-by: Stefan Hajnoczi >> --- >> tests/libqtest.c | 29 ++++++++++++++++++++++++++--- >> 1 file changed, 26 insertions(+), 3 deletions(-) >> >> diff --git a/tests/libqtest.c b/tests/libqtest.c >> index 8b2b2d7..09a0481 100644 >> --- a/tests/libqtest.c >> +++ b/tests/libqtest.c >> @@ -44,6 +44,7 @@ struct QTestState >> bool irq_level[MAX_IRQ]; >> GString *rx; >> pid_t qemu_pid; /* our child QEMU process */ >> + struct sigaction sigact_old; /* restored on exit */ >> }; >> >> #define g_assert_no_errno(ret) do { \ >> @@ -88,6 +89,11 @@ static int socket_accept(int sock) >> return ret; >> } >> >> +static void sigabrt_handler(int signo) >> +{ >> + qtest_end(); Don't you have to re-raise SIGABRT here, to actually terminate the process? >> +} >> + >> QTestState *qtest_init(const char *extra_args) >> { >> QTestState *s; [...]