diff options
author | hrs <hrs@FreeBSD.org> | 2013-08-06 02:14:30 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2013-08-06 02:14:30 +0000 |
commit | fadcfc6c44f94fe8c3be5674744fcb211aa77831 (patch) | |
tree | 5aa9ec1696ac160a50de5f29aa240a8700d3e6c1 | |
parent | 271fe456c422e9d69c3d1c276aba7e8572c9124d (diff) | |
download | FreeBSD-src-fadcfc6c44f94fe8c3be5674744fcb211aa77831.zip FreeBSD-src-fadcfc6c44f94fe8c3be5674744fcb211aa77831.tar.gz |
- 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
-rw-r--r-- | sys/dev/filemon/filemon.c | 11 | ||||
-rw-r--r-- | sys/dev/filemon/filemon_wrapper.c | 1 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index c82a816..ce84e3d 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -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: diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c index 83ff94f..2c6f20e 100644 --- a/sys/dev/filemon/filemon_wrapper.c +++ b/sys/dev/filemon/filemon_wrapper.c @@ -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. */ |