- Use pget(PGET_CANDEBUG | PGET_NOTWEXIT) to determine if the specified
PID is valid for monitoring in FILEMON_SET_PID ioctl. - Set the monitored PID to -1 when the process exits. Suggested by: jilles Tested by: sjg MFC after: 3 days
This commit is contained in:
parent
804d1cc1b6
commit
89cac24e48
@ -164,13 +164,12 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused,
|
||||
|
||||
/* Set the monitored process ID. */
|
||||
case FILEMON_SET_PID:
|
||||
p = pfind(*((pid_t *)data));
|
||||
if (p == NULL)
|
||||
return (EINVAL);
|
||||
error = p_candebug(curthread, p);
|
||||
if (error == 0)
|
||||
error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT,
|
||||
&p);
|
||||
if (error == 0) {
|
||||
filemon->pid = p->p_pid;
|
||||
PROC_UNLOCK(p);
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -574,6 +574,7 @@ filemon_wrapper_sys_exit(struct thread *td, struct sys_exit_args *uap)
|
||||
(uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec);
|
||||
|
||||
filemon_output(filemon, filemon->msgbufr, len);
|
||||
filemon->pid = -1;
|
||||
}
|
||||
|
||||
/* Unlock the found filemon structure. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user