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
This commit is contained in:
Bryan Drewery 2016-03-08 18:05:02 +00:00
parent 26802705d3
commit 7b245cb846

View File

@ -224,12 +224,18 @@ main(int argc, char *argv[])
warn("fork");
done(1);
}
if (child == 0)
doshell(argv);
close(slave);
if (child == 0) {
if (fflg) {
int pid;
if (fflg && ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
err(1, "Cannot set filemon PID");
pid = getpid();
if (ioctl(fm_fd, FILEMON_SET_PID, &pid) < 0)
err(1, "Cannot set filemon PID");
}
doshell(argv);
}
close(slave);
start = tvec = time(0);
readstdin = 1;