svn commit: r296524 - head/usr.bin/script

Bryan Drewery bdrewery at FreeBSD.org
Tue Mar 8 18:05:03 UTC 2016


Author: bdrewery
Date: Tue Mar  8 18:05:02 2016
New Revision: 296524
URL: https://svnweb.freebsd.org/changeset/base/296524

Log:
  Filemon: Attach from the child to avoid racing with the parent attach.
  
  This is the same as how the bmake filemon usage works.
  
  This also fixes failed attach not properly flushing the TTY.
  
  MFC after:	1 week
  Relnotes:	yes
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/usr.bin/script/script.c

Modified: head/usr.bin/script/script.c
==============================================================================
--- head/usr.bin/script/script.c	Tue Mar  8 17:58:02 2016	(r296523)
+++ head/usr.bin/script/script.c	Tue Mar  8 18:05:02 2016	(r296524)
@@ -224,13 +224,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