From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17499 invoked by alias); 19 Jun 2003 11:37:57 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 17478 invoked from network); 19 Jun 2003 11:37:57 -0000 Received: from unknown (HELO localhost.localdomain) (195.113.19.66) by sources.redhat.com with SMTP; 19 Jun 2003 11:37:57 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h5JBbsqO006936; Thu, 19 Jun 2003 13:37:54 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id h5JBbr7U006934; Thu, 19 Jun 2003 13:37:53 +0200 Resent-Message-Id: <200306191137.h5JBbr7U006934@sunsite.ms.mff.cuni.cz> Date: Thu, 19 Jun 2003 11:37:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix test-skeleton.c timeout handling Message-ID: <20030619094554.GS20507@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Resent-From: jakub@sunsite.ms.mff.cuni.cz Resent-Date: Thu, 19 Jun 2003 13:37:53 +0200 Resent-To: Ulrich Drepper , Roland McGrath , Glibc hackers X-SW-Source: 2003-06/txt/msg00038.txt.bz2 Hi! If waitpid returns 0, timeout_handler would still happily access the random value in status. 2003-06-19 Jakub Jelinek * test-skeleton.c (timeout_handler): If waitpid returned 0, retry once after a second. If killed == 0, assume WTERMSIG (status) == SIGKILL. --- libc/test-skeleton.c.jj 2003-06-07 19:23:01.000000000 -0400 +++ libc/test-skeleton.c 2003-06-19 05:40:53.000000000 -0400 @@ -140,9 +140,14 @@ timeout_handler (int sig __attribute__ ( /* Wait for it to terminate. */ killed = waitpid (pid, &status, WNOHANG|WUNTRACED); + if (killed == 0) + { + sleep (1); + killed = waitpid (pid, &status, WNOHANG|WUNTRACED); + } if (killed != 0 && killed != pid) { - perror ("Failed to killed test process"); + perror ("Failed to kill test process"); exit (1); } @@ -156,7 +161,7 @@ timeout_handler (int sig __attribute__ ( exit (0); #endif - if (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL) + if (killed == 0 || (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL)) fputs ("Timed out: killed the child process\n", stderr); else if (WIFSTOPPED (status)) fprintf (stderr, "Timed out: the child process was %s\n", Jakub