From owner-freebsd-hackers@FreeBSD.ORG Thu May 20 14:43:14 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 B787B106564A; Thu, 20 May 2010 14:43:14 +0000 (UTC) (envelope-from dkmcnulty@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 221058FC1A; Thu, 20 May 2010 14:43:13 +0000 (UTC) Received: by fxm4 with SMTP id 4so2544845fxm.13 for ; Thu, 20 May 2010 07:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=pBIIQEhZPW5/qqgUr556oDmF2WvEg4quodaszs6CBqM=; b=s0snGbhIV1+2YL/u/3kZtPscHcwCaA7fQ+S5YP80xiepJ94xtxBwDGtboQ9Fc30KM8 C6uprLba9c/rpIZCpVA5pI0YFxRh7P1OSUwfoLxbgx0qf9g8yJou1B4Q2PyCWXoQpXpD KWsWdws2vsd1PmLGBKfTRvRd1ylI+Zj/8lhKM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=QpnMvfiAmE5EN2ueSsTF+MIQ4yMc9NcroNc7E7w3FmtT1XCXeDe4eA7uDWytAzsNpd F3jNklUOUV13uKwKNzGEwmDbRnp4lWkyCpMVeLN+uOb6PLQF0j61Xn8nsSzgYG62v21y Wij1hmZiQWr3h+WtNdV7wTtX+4fQCQawC+MSY= MIME-Version: 1.0 Received: by 10.239.190.72 with SMTP id w8mr14258hbh.117.1274366592816; Thu, 20 May 2010 07:43:12 -0700 (PDT) Received: by 10.239.153.198 with HTTP; Thu, 20 May 2010 07:43:12 -0700 (PDT) In-Reply-To: <20100519215139.GZ6175@elvis.mu.org> References: <20100518074054.GE6175@elvis.mu.org> <20100519215139.GZ6175@elvis.mu.org> Date: Thu, 20 May 2010 09:43:12 -0500 Message-ID: From: Dan McNulty To: Alfred Perlstein Content-Type: text/plain; charset=ISO-8859-1 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: Thu, 20 May 2010 14:43:14 -0000 On Wed, May 19, 2010 at 4:51 PM, Alfred Perlstein wrote: > * 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 Unfortunately, writing a patch for the FreeBSD kernel may be beyond the scope of my current work. Although I wouldn't mind working on it in my spare time outside of my job. Maybe in some free time this summer. I think the ideal fix for my problem would be to implement a mechanism similar to the Linux ptrace interface that sends a SIGTRAP for events such as fork, exec, thread create, etc. Maybe I will poke around in the FreeBSD kernel source and see what I can figure out. Thanks for the help! -Dan >> >> 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 >