svn commit: r296911 - stable/10/usr.bin/script

Bryan Drewery bdrewery at FreeBSD.org
Tue Mar 15 17:05:30 UTC 2016


Author: bdrewery
Date: Tue Mar 15 17:05:28 2016
New Revision: 296911
URL: https://svnweb.freebsd.org/changeset/base/296911

Log:
  MFC r296524:
  
    Filemon: Attach from the child to avoid racing with the parent attach.
  
  Relnotes:	yes

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

Modified: stable/10/usr.bin/script/script.c
==============================================================================
--- stable/10/usr.bin/script/script.c	Tue Mar 15 15:53:37 2016	(r296910)
+++ stable/10/usr.bin/script/script.c	Tue Mar 15 17:05:28 2016	(r296911)
@@ -221,13 +221,19 @@ main(int argc, char *argv[])
 		warn("fork");
 		done(1);
 	}
-	if (child == 0)
+	if (child == 0) {
+		if (fflg) {
+			int pid;
+
+			pid = getpid();
+			if (ioctl(fm_fd, FILEMON_SET_PID, &pid) < 0)
+				err(1, "Cannot set filemon PID");
+		}
+
 		doshell(argv);
+	}
 	close(slave);
 
-	if (fflg && ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
-		err(1, "Cannot set filemon PID");
-
 	start = tvec = time(0);
 	readstdin = 1;
 	for (;;) {


More information about the svn-src-all mailing list