From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFRey-00048Z-Ae for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:07:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFRes-0004bz-BE for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:07:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFRes-0004br-3F for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:07:06 -0500 From: Markus Armbruster References: <1392651898-16749-1-git-send-email-stefanha@redhat.com> <1392651898-16749-4-git-send-email-stefanha@redhat.com> <530235F0.2040406@redhat.com> Date: Mon, 17 Feb 2014 18:00:03 +0100 In-Reply-To: <530235F0.2040406@redhat.com> (Paolo Bonzini's message of "Mon, 17 Feb 2014 17:16:48 +0100") Message-ID: <87a9dpsmi4.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: Paolo Bonzini Cc: Peter Maydell , Anthony Liguori , qemu-devel@nongnu.org, Stefan Hajnoczi , Andreas Faerber Paolo Bonzini writes: > Il 17/02/2014 16:44, Stefan Hajnoczi ha scritto: >> } >> >> +static void sigabrt_handler(int signo) >> +{ >> + qtest_end(); >> +} >> + > > void qtest_quit(QTestState *s) > { > int status; > > if (s->qemu_pid != -1) { > kill(s->qemu_pid, SIGTERM); > waitpid(s->qemu_pid, &status, 0); > } > > close(s->fd); > close(s->qmp_fd); > g_string_free(s->rx, true); > g_free(s); > } > > Not async-signal safe. You need to ignore the g_string_free and > g_free (perhaps even the closes) if calling from the sigabrt_handler. kill(), waitpid() and close() are all async-signal-safe. SIGABRT is normally synchronous enough: it's sent by abort(). But of course, nothing stops the user from kill -ABRT. Or GLib from calling abort() in some place where an attempt to reenter it crashes & burns. Not sure I'd care, but I'm pretty sure I don't care for freeing stuff on exit :)