From owner-svn-src-all@FreeBSD.ORG Fri Apr 30 22:33:49 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 82572106566C; Fri, 30 Apr 2010 22:33:49 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 723BA8FC16; Fri, 30 Apr 2010 22:33:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3UMXnOW099320; Fri, 30 Apr 2010 22:33:49 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3UMXnW6099318; Fri, 30 Apr 2010 22:33:49 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201004302233.o3UMXnW6099318@svn.freebsd.org> From: Ed Schouten Date: Fri, 30 Apr 2010 22:33:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207453 - head/usr.bin/script X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2010 22:33:49 -0000 Author: ed Date: Fri Apr 30 22:33:49 2010 New Revision: 207453 URL: http://svn.freebsd.org/changeset/base/207453 Log: Remove WNOHANG flag from wait3(). Because script(1) now reliably terminates when the TTY is closed, it may be the case that the call to wait3() occurs just before the child process exits. This causes error codes to be ignored. Just change script(1) to use waitpid() instead of wait3(). This makes it more portable and prevents the need for a loop, since waitpid() only returns a specified process. PR: bin/146189 Tested by: amdmi3@, older version MFC after: 2 weeks Modified: head/usr.bin/script/script.c Modified: head/usr.bin/script/script.c ============================================================================== --- head/usr.bin/script/script.c Fri Apr 30 22:31:37 2010 (r207452) +++ head/usr.bin/script/script.c Fri Apr 30 22:33:49 2010 (r207453) @@ -219,23 +219,17 @@ usage(void) void finish(void) { - pid_t pid; - int die, e, status; + int e, status; - die = e = 0; - while ((pid = wait3(&status, WNOHANG, 0)) > 0) - if (pid == child) { - die = 1; - if (WIFEXITED(status)) - e = WEXITSTATUS(status); - else if (WIFSIGNALED(status)) - e = WTERMSIG(status); - else /* can't happen */ - e = 1; - } - - if (die) + if (waitpid(child, &status, 0) == child) { + if (WIFEXITED(status)) + e = WEXITSTATUS(status); + else if (WIFSIGNALED(status)) + e = WTERMSIG(status); + else /* can't happen */ + e = 1; done(e); + } } void