From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 8 17:20:10 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6EFB8787; Thu, 8 Aug 2013 17:20:10 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 431962629; Thu, 8 Aug 2013 17:20:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r78HKAHF065926; Thu, 8 Aug 2013 17:20:10 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r78HK9j4065920; Thu, 8 Aug 2013 17:20:09 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201308081720.r78HK9j4065920@svn.freebsd.org> From: Hiroki Sato Date: Thu, 8 Aug 2013 17:20:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r254096 - in stable: 8/sys/dev/filemon 9/sys/dev/filemon X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2013 17:20:10 -0000 Author: hrs Date: Thu Aug 8 17:20:09 2013 New Revision: 254096 URL: http://svnweb.freebsd.org/changeset/base/254096 Log: MFC 253887,253977: - 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 Modified: stable/8/sys/dev/filemon/filemon.c stable/8/sys/dev/filemon/filemon_wrapper.c Directory Properties: stable/8/sys/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/dev/filemon/filemon.c stable/9/sys/dev/filemon/filemon_wrapper.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/8/sys/dev/filemon/filemon.c ============================================================================== --- stable/8/sys/dev/filemon/filemon.c Thu Aug 8 16:09:20 2013 (r254095) +++ stable/8/sys/dev/filemon/filemon.c Thu Aug 8 17:20:09 2013 (r254096) @@ -180,6 +180,7 @@ filemon_ioctl(struct cdev *dev, u_long c { int error = 0; struct filemon *filemon; + struct proc *p; #if __FreeBSD_version < 701000 filemon = dev->si_drv1; @@ -202,7 +203,12 @@ filemon_ioctl(struct cdev *dev, u_long c /* Set the monitored process ID. */ case FILEMON_SET_PID: - filemon->pid = *((pid_t *) data); + error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT, + &p); + if (error == 0) { + filemon->pid = p->p_pid; + PROC_UNLOCK(p); + } break; default: Modified: stable/8/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- stable/8/sys/dev/filemon/filemon_wrapper.c Thu Aug 8 16:09:20 2013 (r254095) +++ stable/8/sys/dev/filemon/filemon_wrapper.c Thu Aug 8 17:20:09 2013 (r254096) @@ -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. */