[Mimedefang] Like action_replace_with_url(), but not quite

Nathan Findley nathan at zenlok.com
Fri Aug 31 00:56:12 EDT 2012

On 08/31/2012 12:21 PM, David F. Skoll wrote:
> On Fri, 31 Aug 2012 10:54:00 +0900
> Nathan Findley <nathan at zenlok.com> wrote:
>>   From our more knowledgeable mimedefang users, I would appreciate an
>> explanation about what is happening in the mimedefang.pl
>> "resend_message_specifying_mode" method. The child execs sendmail.
>> The message data is sitting in the child process's STDIN, correct?
> Nope.  The real magic happens here:
>      $pid = open(CHILD, "|-");
> This forks a process and connects STDIN of the child process to the
> CHILD descriptor in the parent.
>> { exec($sm, @cmd); } <-- how is sendmail receiving the contents of
>> the message? I don't see any explicit piping happening.
> Whatever the parent process writes to the CHILD descriptor shows up on
> STDIN of the child.  As in:
>      if ($pid) {   # In the parent -- pipe mail message to the child
>          print CHILD $body;
>          close(CHILD);
>          return;
>      }
> And you can stream messages in filter_end if you like.
When CHILD calls exec how is it that sendmail able to find the message 
data on STDIN? Does calling exec always pass any existing STDIN data to 
the executed command? It seems to me that this is what is happening. I 
simply had no idea that if a parent process (CHILD in this case) has 
data in STDIN and then calls exec the STDIN data will be passed to the 
program being called (sendmail in this case).



More information about the MIMEDefang mailing list