diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2016-03-15 17:05:28 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2016-03-15 17:05:28 +0000 |
commit | 9f9f925e251c4a438f048762406daa5dee3f7900 (patch) | |
tree | 767049498d3c59bab79428d4633f9c6218f97f89 /usr.bin/script | |
parent | f4004c8edabeea33669971e1dad93526501fe2b1 (diff) | |
download | FreeBSD-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/script')
-rw-r--r-- | usr.bin/script/script.c | 14 |
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 (;;) { |