From: Daniel Vetter Subject: [PATCH 5/7] lib/drmtest: make signal process cleanup more robust Date: Mon, 12 Aug 2013 11:09:59 +0200 Message-ID: <1376298601-18641-6-git-send-email-daniel.vetter@ffwll.ch> References: <1376298601-18641-1-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com [209.85.215.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 458A7E6093 for ; Mon, 12 Aug 2013 02:10:17 -0700 (PDT) Received: by mail-ea0-f172.google.com with SMTP id r16so3336479ead.3 for ; Mon, 12 Aug 2013 02:10:16 -0700 (PDT) In-Reply-To: <1376298601-18641-1-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Intel Graphics Development Cc: Daniel Vetter List-Id: intel-gfx@lists.freedesktop.org If we skip a test and and fail somewhere the parent might die before the child. So add some cleanup to handle this case. Also make sure that the parent indeed waits for the child to die. This is required to make the latest version of the piglit runner happy, it tends to wait for all zombies to disappear. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 767c8dc..77e8002 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -625,11 +625,18 @@ static void sig_handler(int i) sig_stat++; } +static void signal_helper_exit_handler(int sig) +{ + drmtest_stop_signal_helper(); +} + void drmtest_fork_signal_helper(void) { pid_t pid; sighandler_t oldsig; + drmtest_install_exit_handler(signal_helper_exit_handler); + signal(SIGUSR1, sig_handler); oldsig = signal(SIGQUIT, SIG_DFL); pid = fork(); @@ -644,8 +651,12 @@ void drmtest_fork_signal_helper(void) void drmtest_stop_signal_helper(void) { - if (signal_helper != -1) + int exitcode; + + if (signal_helper != -1) { kill(signal_helper, SIGQUIT); + wait(&exitcode); + } if (sig_stat) fprintf(stdout, "signal handler called %llu times\n", sig_stat); -- 1.8.3.2