[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: process pipes

From: Eric Blake
Subject: Re: process pipes
Date: Thu, 30 Apr 2009 22:07:34 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090302 Thunderbird/ Mnenhy/

Hash: SHA1

According to address@hidden on 4/30/2009 6:55 PM:
> Hello, what is the treatment of processes using esyscmd in m4?
> what becomes of stdin and the other file descriptors when a
> process is invoked from within m4?

The original stdin and stdout of the parent process remain open in the
parent for use after the child process completes, but the child process
cannot see them.  The original stderr of the parent process is passed on
to the child.  Any other fd's that were inherited into the parent process
are carried on to the child, but all other fd's opened by m4 itself are
marked close-on-exec to hide them from the child.  M4 takes great pains to
ensure that if it was started with stdin, stdout, or stderr closed, then
the child process will not see spurious files for stdin/stdout and will
also have closed stderr (many other applications are rather cavalier about
assuming that stdin/stdout won't be closed, and gladly stomp on the wrong
data when this scenario happens).

Currently, m4 blocks until it hits EOF on the child process, reading the
entire output from the child process into memory.  A smarter design would
allow operating on blocks of input from the child process as they become
available; patches welcome.

> In what way might the output of a shell program be piped into an
> m4 script so that it may be used as a filter program?

In what way do you mean?  'echo foo | m4' works just like any other Unixy

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]