From ab4e7f259353bff18b88a7b9e15f96a497fcd188 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Tue, 15 Mar 2016 19:45:24 +0000 Subject: [PATCH] MFS r296911: Filemon: Attach from the child to avoid racing with the parent attach. Relnotes: yes Approved by: re (marius) git-svn-id: svn://svn.freebsd.org/base/releng/10.3@296917 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.bin/script/script.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index 4e5e31372..1fb79f3b4 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 (;;) { -- 2.45.0