From owner-freebsd-current@FreeBSD.ORG Mon Dec 15 04:49:48 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 76F6C16A4CE; Mon, 15 Dec 2003 04:49:48 -0800 (PST) Received: from schlepper.zs64.net (schlepper.zs64.net [212.12.50.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2DC1B43D33; Mon, 15 Dec 2003 04:49:44 -0800 (PST) (envelope-from cracauer@schlepper.zs64.net) Received: from schlepper.zs64.net (schlepper [212.12.50.230]) by schlepper.zs64.net (8.12.10/8.11.1) with ESMTP id hBFCngZR059425; Mon, 15 Dec 2003 13:49:42 +0100 (CET) (envelope-from cracauer@schlepper.zs64.net) Received: (from cracauer@localhost) by schlepper.zs64.net (8.12.10/8.12.9/Submit) id hBFCngbX059424; Mon, 15 Dec 2003 07:49:42 -0500 (EST) Date: Mon, 15 Dec 2003 07:49:42 -0500 From: Martin Cracauer To: Maxim Konovalov Message-ID: <20031215074942.A59308@cons.org> References: <3EEDD6E2.6040505@mail.ru> <20031215151613.E7304@news1.macomnet.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20031215151613.E7304@news1.macomnet.ru>; from maxim@macomnet.ru on Mon, Dec 15, 2003 at 03:35:31PM +0300 cc: cracauer@FreeBSD.ORG cc: current@FreeBSD.ORG cc: Alexander Nedotsukov cc: bde@FreeBSD.ORG 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 12:49:48 -0000 [CC'ed Bruce] Maxim Konovalov wrote on Mon, Dec 15, 2003 at 03:35:31PM +0300: > Hello, > > On Mon, 16 Jun 2003, 23:40+0900, Alexander Nedotsukov wrote: > > > All, > > > > I found current truss behaviour a bit strange. It coredumps always if > > trussed process do without any significant reason for my understanding. > > I also confused with comment for commit originally introduced this > > functionality > > http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/truss/main.c.diff?r1=1.9&r2=1.10. > > I propose patch attached to make truss always return result of trussed > > process and do not kill() itself. What do you think about it? > > As a matter of fact, bin/58970 is a backout of rev.1.10 truss/main.c: > > ---------------------------- > revision 1.10 > date: 1998/08/24 10:17:20; author: cracauer; state: Exp; lines: +9 -1 > When exiting on SIGINT, exit with signal status > ============================================================================= > > But a code does not match the comment and does something funny: > > @@ -216,6 +217,7 @@ > break; > case S_SIG: > fprintf(outfile, "SIGNAL %lu\n", pfs.val); > + sigexit = pfs.val; > break; > case S_EXIT: > fprintf (outfile, "process exit, rval = %lu\n", pfs.val); > @@ -232,5 +234,11 @@ > if (ioctl(Procfd, PIOCCONT, val) == -1) > warn("PIOCCONT"); > } while (pfs.why != S_EXIT); > + if (sigexit) { > + if (sigexit == SIGQUIT) > + exit(sigexit); > + (void) signal(sigexit, SIG_DFL); > + (void) kill(getpid(), sigexit); > + } > return 0; > } > > Gentlemen, does anobody know what is going on there? If you catch a signal like SIGINT or SIGTERM (as opposed to leaving the original OS handler to handle it), then you need to reissue that same signal to yourself when after your did whatever cleanup you want. The general reason is that the parent of the process needs to be informed that you exited on a signal. The specific reason is that if you don't, then a shellscript will not be interruptable with SIGINT or SIGTERM. I have a lengthly web page about it at http://www.cons.org/cracauer/sigint.html As for for problem with the coredumps, I assume this is when SIGQUIT is used? The proper way of handling this would be to change truss (and other transparent wrappers) to ulimit the coredump size to zero and then reissue the SIGQUIT signal. But the integrety towards the parent needs to be maintained, you must not exit without a signal exit status or you get runaway scripts. Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/ No warranty. This email is probably produced by one of my cats stepping on the keys. No, I don't have an infinite number of cats.