How does Sendmail know how it was invoked?

RW fbsd06 at mlists.homeunix.com
Sat Aug 4 14:13:46 PDT 2007


On Sat, 4 Aug 2007 15:48:11 -0500
Don Hinton <don.hinton at vanderbilt.edu> 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.



More information about the freebsd-questions mailing list