From owner-freebsd-ports Thu Dec 12 21:50:04 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id VAA20731 for ports-outgoing; Thu, 12 Dec 1996 21:50:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id VAA20721; Thu, 12 Dec 1996 21:50:02 -0800 (PST) Resent-Date: Thu, 12 Dec 1996 21:50:02 -0800 (PST) Resent-Message-Id: <199612130550.VAA20721@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-ports Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, dawes@physics.usyd.edu.au Received: from landfill.physics.usyd.edu.au (landfill.physics.usyd.edu.au [129.78.129.18]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id VAA20222 for ; Thu, 12 Dec 1996 21:44:14 -0800 (PST) Received: (from dawes@localhost) by landfill.physics.usyd.edu.au (8.8.2/8.8.2) id QAA10123; Fri, 13 Dec 1996 16:43:56 +1100 (EST) Message-Id: <199612130543.QAA10123@landfill.physics.usyd.edu.au> Date: Fri, 13 Dec 1996 16:43:56 +1100 (EST) From: dawes@physics.usyd.edu.au Reply-To: dawes@physics.usyd.edu.au To: FreeBSD-gnats-submit@freebsd.org Cc: dawes@physics.usyd.edu.au X-Send-Pr-Version: 3.2 Subject: ports/2203: Team's exit status doesn't indicate if there were I/O errors Sender: owner-ports@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2203 >Category: ports >Synopsis: Team's exit status doesn't indicate if there were I/O errors >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Dec 12 21:50:01 PST 1996 >Last-Modified: >Originator: David Dawes >Organization: University of Sydney, Australia >Release: FreeBSD 3.0-CURRENT i386 >Environment: >Description: Team's exit status will be 0 even if there is an I/O error. The reason is that the exit status of the "guys" isn't checked. >How-To-Repeat: Set team's stderr to a file so it doesn't prompt the user on an I/O error, and use it to write enough to overfill a device. Check the exit status, and note that it is zero. >Fix: The following patch fixes this problem. *** Makefile.ORIG Fri Dec 13 16:26:46 1996 --- Makefile Fri Dec 13 16:27:19 1996 *************** *** 3,8 **** BINDIR= ${PREFIX}/bin MANDIR= ${PREFIX}/man/man ! CFLAGS+= -DHAVE_PARAM_H .include --- 3,8 ---- BINDIR= ${PREFIX}/bin MANDIR= ${PREFIX}/man/man ! CFLAGS+= -DHAVE_PARAM_H -DHAVE_WAIT_H .include *** team.c.ORIG Fri Dec 13 16:26:50 1996 --- team.c Fri Dec 13 16:28:14 1996 *************** *** 84,89 **** --- 84,92 ---- #include #include #include + #ifdef HAVE_WAIT_H + #include + #endif #ifdef HAVE_PARAM_H #include *************** *** 165,170 **** --- 168,174 ---- local bool verbose = false; local bool report = true; + local bool guyhaderror = false; extern int errno; local time_t origin; *************** *** 647,653 **** { mesg("team: guy pid %u: %s\n",guy->pid,errormsg); call GuySEND(guy,TokenABORT,FdERROR,0L); ! exit(1); /*NOTREACHED*/ } --- 651,657 ---- { mesg("team: guy pid %u: %s\n",guy->pid,errormsg); call GuySEND(guy,TokenABORT,FdERROR,0L); ! exit(2); /*NOTREACHED*/ } *************** *** 874,879 **** --- 878,891 ---- --team->active; + #ifdef WIFEXITED + /* If a guy had an error, its exit status is 2. Also catch a killed guy */ + if ((WIFEXITED(status) && WEXITSTATUS(status) == 2) || + (WIFSIGNALED(status) && WTERMSIG(status) != SIGPIPE)) { + guyhaderror = true; + } + #endif + if (status != 0 && team->active != 0) return false; } *************** *** 1042,1047 **** --- 1054,1065 ---- origin = time((time_t *) 0); + /* + * Ignore SIGPIPE. The parent or some guys can get this signal at the end, + * and it affects the exit status reporting. + */ + signal(SIGPIPE, SIG_IGN); + if (!TeamStart(&team,bufsize,isize,osize)) { mesg("team: cannot start the team\n"); *************** *** 1062,1067 **** --- 1080,1091 ---- if (!TeamClose(&team)) { mesg("team: cannot close the team\n"); + return 1; + } + + if (guyhaderror) + { + mesg("team: guy had error\n"); return 1; } >Audit-Trail: >Unformatted: