From owner-freebsd-current@FreeBSD.ORG Mon Dec 15 13:29:29 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A7D7516A4CE; Mon, 15 Dec 2003 13:29:29 -0800 (PST) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03A1543D6B; Mon, 15 Dec 2003 13:29:04 -0800 (PST) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.12.9p2/8.12.9) with ESMTP id hBFLSoeF068231; Mon, 15 Dec 2003 13:28:54 -0800 (PST) (envelope-from truckman@FreeBSD.org) Message-Id: <200312152128.hBFLSoeF068231@gw.catspoiler.org> Date: Mon, 15 Dec 2003 13:28:50 -0800 (PST) From: Don Lewis To: cracauer@cons.org In-Reply-To: <20031215161928.A68001@cons.org> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: cracauer@FreeBSD.org cc: current@FreeBSD.org cc: bland@mail.ru Subject: Re: truss issue X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Dec 2003 21:29:29 -0000 On 15 Dec, Martin Cracauer wrote: > Don Lewis wrote on Mon, Dec 15, 2003 at 01:13:58PM -0800: >> Hmn, I wonder if it would be cleaner to exec() the executable to be >> traced in the parent process and run truss in the child ... > > I think I misunderstand. The parent is usually your login shell, you > don't want that one to exec() anything. If you type "truss foo" at the shell prompt, the shell will fork and exec truss, which forks and execs foo. When truss forks, the child process is the one that execs foo, and the parent process watches what the child process does. My suggestion is to swap the roles of the parent and child truss processes. The parent truss process would be the one that calls exec(), and the child process would be the one doing the monitoring. When the process being traced exits, the shell would automagically get the correct exit status. There are probably some complications that I'm overlooking, but ...