Date: Fri, 13 Dec 1996 16:43:56 +1100 (EST) From: dawes@physics.usyd.edu.au To: FreeBSD-gnats-submit@freebsd.org Cc: dawes@physics.usyd.edu.au Subject: ports/2203: Team's exit status doesn't indicate if there were I/O errors Message-ID: <199612130543.QAA10123@landfill.physics.usyd.edu.au> Resent-Message-ID: <199612130550.VAA20721@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <bsd.prog.mk> --- 3,8 ---- BINDIR= ${PREFIX}/bin MANDIR= ${PREFIX}/man/man ! CFLAGS+= -DHAVE_PARAM_H -DHAVE_WAIT_H .include <bsd.prog.mk> *** team.c.ORIG Fri Dec 13 16:26:50 1996 --- team.c Fri Dec 13 16:28:14 1996 *************** *** 84,89 **** --- 84,92 ---- #include <sys/file.h> #include <sys/stat.h> #include <fcntl.h> + #ifdef HAVE_WAIT_H + #include <sys/wait.h> + #endif #ifdef HAVE_PARAM_H #include <sys/param.h> *************** *** 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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612130543.QAA10123>