Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Mar 2016 18:05:02 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r296524 - head/usr.bin/script
Message-ID:  <201603081805.u28I52R8064839@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 (;;) {



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