Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 May 2010 12:34:06 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r208070 - stable/8/usr.bin/script
Message-ID:  <201005141234.o4ECY6XW056284@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri May 14 12:34:06 2010
New Revision: 208070
URL: http://svn.freebsd.org/changeset/base/208070

Log:
  MFC r207453:
  
    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

Modified:
  stable/8/usr.bin/script/script.c
Directory Properties:
  stable/8/usr.bin/script/   (props changed)

Modified: stable/8/usr.bin/script/script.c
==============================================================================
--- stable/8/usr.bin/script/script.c	Fri May 14 10:06:20 2010	(r208069)
+++ stable/8/usr.bin/script/script.c	Fri May 14 12:34:06 2010	(r208070)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005141234.o4ECY6XW056284>