From owner-freebsd-questions@FreeBSD.ORG Sat Aug 4 21:13:46 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1558B16A41F for ; Sat, 4 Aug 2007 21:13:46 +0000 (UTC) (envelope-from fbsd06@mlists.homeunix.com) Received: from mxout-03.mxes.net (mxout-03.mxes.net [216.86.168.178]) by mx1.freebsd.org (Postfix) with ESMTP id EEB4713C461 for ; Sat, 4 Aug 2007 21:13:45 +0000 (UTC) (envelope-from fbsd06@mlists.homeunix.com) Received: from gumby.homeunix.com. (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id 3C58B5197B for ; Sat, 4 Aug 2007 17:13:44 -0400 (EDT) Date: Sat, 4 Aug 2007 22:13:41 +0100 From: RW To: freebsd-questions@freebsd.org Message-ID: <20070804221341.6880cbb4@gumby.homeunix.com.> In-Reply-To: <200708041548.11996.don.hinton@vanderbilt.edu> References: <20070804190634.69234e1e@gumby.homeunix.com.> <20070804182307.GD77822@dan.emsphone.com> <20070804211334.782c37ff@gumby.homeunix.com.> <200708041548.11996.don.hinton@vanderbilt.edu> X-Mailer: Claws Mail 2.10.0 (GTK+ 2.10.14; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: How does Sendmail know how it was invoked? 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: Sat, 04 Aug 2007 21:13:46 -0000 On Sat, 4 Aug 2007 15:48:11 -0500 Don Hinton wrote: > On Saturday 04 August 2007 15:13:34 RW wrote: > > On Sat, 4 Aug 2007 13:23:07 -0500 > > > > What I didn't get was that when a binary is executed from execve(), > > it's the parent program that sets the argv[0] seen by the child, > > and not the kernel. > > Sorry, I should have paid closer attention to your question and > actually looked at the code to see what they were doing in this > specific case. > > They original args, including argv[0], are passed as args parameter > to execve. So from the perspective of the called application, the > original argv[0] is now argv[1]. I don't think that's right. As I understand it, the argv argument to execve() is passed-on directly as the child processes arguments, and the parent can write whatever it likes into argv[0] - it's only convention that it's a filename. So mailwrapper passes its own argv[0] as sendmail's argv[0]. And so sendmail behaves as if it had been invoked as mailq or whatever.