From owner-freebsd-questions@FreeBSD.ORG Tue May 4 16:02:50 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 64FDD106564A for ; Tue, 4 May 2010 16:02:50 +0000 (UTC) (envelope-from dkmcnulty@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.157]) by mx1.freebsd.org (Postfix) with ESMTP id EA8DD8FC15 for ; Tue, 4 May 2010 16:02:49 +0000 (UTC) Received: by fg-out-1718.google.com with SMTP id 22so1106996fge.13 for ; Tue, 04 May 2010 09:02:40 -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 :content-transfer-encoding; bh=JP5z1mC6csyqX86/F4XOtaip35iubyVA/1GXqm9SBwk=; b=Z5CCEmUqz6PqSg5aAjFbQ7PlgDd4N9VmdzJAs9kv1X6p/pfZp+kBpHcTrdi3MMc96J 31zzoj2NjYNB63cSKGa3z9JFgMGzD3OOqfJiyeXo9dzpw9Hr8FgWQ0FDyK0/UDw5VmEB dnFQDepfWV81eoPY/+v/dmM06Q3K9P6fY4n0I= 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:content-transfer-encoding; b=LC3mdpyB+Rb/ksGNvAOwz8wjKzNgqmUmITKXyknStpKjdHJa29+ylmD3kdmEBg19jW VyewSwqKkG8YeTBbrmmX0AGWFb7ydOUd/qiX2ZOyu8A3l1V0ZVGRW60LIeqhWmrU0KJr m6+wO6eH7QHHxNk0hJu9vNSaic68QvyCYeoVI= MIME-Version: 1.0 Received: by 10.239.155.73 with SMTP id h9mr956439hbc.31.1272988960212; Tue, 04 May 2010 09:02:40 -0700 (PDT) Received: by 10.239.153.198 with HTTP; Tue, 4 May 2010 09:02:40 -0700 (PDT) In-Reply-To: <20100503213936.GL14572@dan.emsphone.com> References: <20100503213936.GL14572@dan.emsphone.com> Date: Tue, 4 May 2010 11:02:40 -0500 Message-ID: From: Dan McNulty To: Dan Nelson Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: Finding out when a child process forks or calls exec X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 16:02:50 -0000 Great! This was what I was looking for. Thanks. -Dan On Mon, May 3, 2010 at 4:39 PM, Dan Nelson wrote: > In the last episode (May 03), Dan McNulty said: >> I am trying to port a debugging tool that uses the ptrace interface from >> Linux to FreeBSD. =A0From what I can tell, the ptrace interface on FreeB= SD >> is pretty similar to the Linux interface; however, it doesn't appear tha= t >> the FreeBSD interface generate events when the child process forks, call= s >> exec, creates a new LWP, etc. =A0My question then is: >> >> Does FreeBSD provide any way to determine from a parent/tracing >> process if a child process has called fork, exec, exit, or created a >> new LWP? > > /usr/bin/truss watches for syscalls named "fork", "rfork", and "vfork", a= nd > when they return it forks another copy of itself to watch the child. =A0S= ee > /usr/src/usr.bin/truss/i386-fbsd.c and main.c (search for "in_fork"). > > You can tell when a new lwp is created because lwpid changes. =A0In setup= .c > the waitevent() function calls ptrace(PT_LWPINFO...) on every syscall > entry/exit so it's easy to track; it then calls the find_thread() functio= n > which allocates a new helper struct every time a new lwp appears. > > -- > =A0 =A0 =A0 =A0Dan Nelson > =A0 =A0 =A0 =A0dnelson@allantgroup.com > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o= rg" >