Date: Tue, 6 Aug 2013 02:14:30 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253977 - head/sys/dev/filemon Message-ID: <201308060214.r762EUsE003281@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hrs Date: Tue Aug 6 02:14:30 2013 New Revision: 253977 URL: http://svnweb.freebsd.org/changeset/base/253977 Log: - 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 Modified: head/sys/dev/filemon/filemon.c head/sys/dev/filemon/filemon_wrapper.c Modified: head/sys/dev/filemon/filemon.c ============================================================================== --- head/sys/dev/filemon/filemon.c Tue Aug 6 01:01:15 2013 (r253976) +++ head/sys/dev/filemon/filemon.c Tue Aug 6 02:14:30 2013 (r253977) @@ -164,13 +164,12 @@ filemon_ioctl(struct cdev *dev, u_long c /* 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: Modified: head/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- head/sys/dev/filemon/filemon_wrapper.c Tue Aug 6 01:01:15 2013 (r253976) +++ head/sys/dev/filemon/filemon_wrapper.c Tue Aug 6 02:14:30 2013 (r253977) @@ -574,6 +574,7 @@ filemon_wrapper_sys_exit(struct thread * (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec); filemon_output(filemon, filemon->msgbufr, len); + filemon->pid = -1; } /* Unlock the found filemon structure. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308060214.r762EUsE003281>