summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-03-08 18:05:02 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-03-08 18:05:02 +0000
commitf234bc3e5459e357aae04d83354e1218c51198fa (patch)
tree1af6dc38e793b77f7419ffce8ee679ccc8140b33 /usr.bin
parentf255ec5f1bcbaa2c4bf17805c664f78a3fb3cbf6 (diff)
downloadFreeBSD-src-f234bc3e5459e357aae04d83354e1218c51198fa.zip
FreeBSD-src-f234bc3e5459e357aae04d83354e1218c51198fa.tar.gz
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
Diffstat (limited to 'usr.bin')
-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 72814fb..49446ef 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 (;;) {
OpenPOWER on IntegriCloud