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. */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to