From owner-freebsd-current@FreeBSD.ORG Mon Sep 19 16:04:07 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 060B4106566B for ; Mon, 19 Sep 2011 16:04:07 +0000 (UTC) (envelope-from freebsd-current@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id 8879B8FC14 for ; Mon, 19 Sep 2011 16:04:06 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R5gKC-00006W-Bl for freebsd-current@freebsd.org; Mon, 19 Sep 2011 18:04:04 +0200 Received: from 178.214.36.169 ([178.214.36.169]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 18:04:04 +0200 Received: from citrin by 178.214.36.169 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 18:04:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org From: Anton Yuzhaninov Date: Mon, 19 Sep 2011 16:03:42 +0000 (UTC) Organization: Vega Lines: 46 Sender: Anton Yuzhaninov Message-ID: References: <4E5E46A4.3060705@citrin.ru> <4E6A99A9.1000204@delphij.net> <864o0adkva.fsf@kopusha.home.net> <86mxe0r8o5.fsf@in138.ua3> X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 178.214.36.169 X-Comment-To: Anton Yuzhaninov User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/9.0-BETA2 (i386)) Subject: Re: truss X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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, 19 Sep 2011 16:04:07 -0000 On Mon, 19 Sep 2011 15:00:31 +0000 (UTC), Anton Yuzhaninov wrote: AY> On Mon, 19 Sep 2011 15:58:02 +0300, Mikolaj Golub wrote: AY>>> ktrace -i for truss sleep 5 AY>>> http://dl.dropbox.com/u/8798217/tmp/truss_ktrace2.txt MG>> MG>> Although ptrace(PT_TRACE_ME,0,0,0) returned 0 the process did not stop after MG>> execve() and wait4() in parent (which was actually waiting for this stop) MG>> returned only after the child exit. No I idea why so far :-). MG>> AY> AY> As I understand SIGTRAP used to stop child process after execve(), but AY> this signal ignored: AY> AY> citrin:~> sleep 300 & AY> citrin:~> procstat -i 1991 | fgrep TRAP AY> 1991 sleep TRAP -I- AY> AY> Under FreeBSD 8, where ptrace works for me, this signal is not ignored: AY> x:~> sleep 300 & AY> x:~> procstat -i 78716 | fgrep TRAP AY> 78716 sleep TRAP --- SIGTRAP is ignored by X window manager used by me, and this is inherited across forks/execs up to the truss. IMHO truss should restore default signal handler for SIGTRAP. With this patch truss works for me: --- usr.bin/truss/main.c (revision 225504) +++ usr.bin/truss/main.c (working copy) @@ -255,6 +255,11 @@ main(int ac, char **av) if (trussinfo->pid == 0) { /* Start a command ourselves */ command = av; + /* + * SIGTRUP used to stop traced process after execve + * un-ignore this signal (it can be ignored by parents) + */ + signal(SIGTRAP, SIG_DFL); trussinfo->pid = setup_and_wait(command); signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); -- Anton Yuzhaninov