From owner-freebsd-hackers@FreeBSD.ORG Wed May 19 21:51:39 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D020106566C for ; Wed, 19 May 2010 21:51:39 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 7D7998FC14 for ; Wed, 19 May 2010 21:51:39 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 5D2941A3D0F; Wed, 19 May 2010 14:51:39 -0700 (PDT) Date: Wed, 19 May 2010 14:51:39 -0700 From: Alfred Perlstein To: Dan McNulty Message-ID: <20100519215139.GZ6175@elvis.mu.org> References: <20100518074054.GE6175@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: freebsd-hackers@freebsd.org Subject: Re: Efficient way to determine when a child process forks or calls exec X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2010 21:51:39 -0000 * Dan McNulty [100519 07:13] wrote: > Thanks for all the great suggestions! > > It looks like the kevent system call is the closest to what I need. > However, I didn't mention this, but I would like the process being > traced to be stopped on entrance to fork, exec, etc. This would be > similar to Linux's ptrace interface which sends a SIGTRAP to the > traced process on exec, fork, etc. From what I could tell so far, > kevent doesn't provide this functionality. > > Am I missing something? Is there a way to get kevent to stop the > process when events occur? Not that I know of off the top of my head. Although if you want to contrib the code I can help get it in. :) -Alfred > > Thanks again for your help, > -Dan > > On Tue, May 18, 2010 at 2:40 AM, Alfred Perlstein wrote: > > * Dan McNulty [100517 08:02] wrote: > >> Hi all, > >> > >> I have been experimenting with ptrace to determine when a child > >> process forks or calls exec. Particularly, I have explored tracing > >> every system call entry and exit similar to what the truss utility > >> does, and for my case, the performance impact of tracing every system > >> call is too great. > >> > >> Is there a more efficient way than tracing every system call entry and > >> exit to determine when a child process forks, calls exec, or creates a > >> new LWP? > >> > >> Thanks a lot for your help! > > > > kevent has some hooks, have you looked at that? > > > > -- > > - Alfred Perlstein > > .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10 > > .- FreeBSD committer > > -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10 .- FreeBSD committer