- 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:
Hiroki Sato 2013-08-06 02:14:30 +00:00
parent 804d1cc1b6
commit 89cac24e48
2 changed files with 6 additions and 6 deletions

View File

@ -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:

View File

@ -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. */