aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2016-03-08 18:05:02 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2016-03-08 18:05:02 +0000
commit7b245cb846ca18c501059c5875a90792baf5821b (patch)
tree1af6dc38e793b77f7419ffce8ee679ccc8140b33
parent26802705d31aee2e827897d68319482f1340d759 (diff)
downloadsrc-7b245cb846ca18c501059c5875a90792baf5821b.tar.gz
src-7b245cb846ca18c501059c5875a90792baf5821b.zip
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
Notes
Notes: svn path=/head/; revision=296524
-rw-r--r--usr.bin/script/script.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 72814fbe17ad..49446ef730ab 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -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 (;;) {