summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-03-15 17:05:28 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-03-15 17:05:28 +0000
commit9f9f925e251c4a438f048762406daa5dee3f7900 (patch)
tree767049498d3c59bab79428d4633f9c6218f97f89 /usr.bin
parentf4004c8edabeea33669971e1dad93526501fe2b1 (diff)
downloadFreeBSD-src-9f9f925e251c4a438f048762406daa5dee3f7900.zip
FreeBSD-src-9f9f925e251c4a438f048762406daa5dee3f7900.tar.gz
MFC r296524:
Filemon: Attach from the child to avoid racing with the parent attach. Relnotes: yes
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 4e5e313..1fb79f3 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -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 (;;) {
OpenPOWER on IntegriCloud