bug-bash
[Top][All Lists]
Advanced

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

omit fork before last exec


From: John Reiser
Subject: omit fork before last exec
Date: Mon, 03 Aug 2009 19:05:34 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2

Hi,

Would it be possible for bash to detect just-in-time the last subprocess
that it will execute, and then do only an 'execve' instead of a fork+execve?
This might save a lot of operating system overhead for process creation:
perhaps upto 10% over the course of a day, especially for most uses of 'make'.

It seems to me that this could work if there are no active traps
and if the shell's input can be re-positioned without penalty.
An active trap might get triggered by the supposed last subprocess;
then interpreting the body of the trap could invalidate the "last subprocess"
property.  If the shell's input cannot be repositioned (is not a regular
file or "-c" command line string; is a pipe, socket, fifo, character device,
etc.) then lookahead on the shell's input is problematic.  Lookahead
is necessary to determine the "last subprocess" property.  However, the
lookahead must be undone before exec so that semantics remain the same
for the case when the shell and a subprocess share the input stream.
Piping input into a shell often relies on alternating consumption of
the piped input by the shell and one or more subprocesses that have
un-redirected stdin.

Comments?

--




reply via email to

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