diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-25 20:31:14 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-25 20:31:14 +0200 |
commit | 1e3e2ccd5dd280371c9ca29c0e0304a0d40592af (patch) | |
tree | 2a6151351436d06fe61e60b4e71e8deab6378d7c /shell/ash_test/ash-signals/signal3.right | |
parent | 86981e3ad2d03e77d1f668ac1603a041be448dae (diff) | |
download | busybox-1e3e2ccd5dd280371c9ca29c0e0304a0d40592af.tar.gz |
ash: [SHELL] Optimize dash -c "command" to avoid a fork
Upstream commit:
Date: Thu, 7 Jul 2011 13:58:48 +0800
[SHELL] Optimize dash -c "command" to avoid a fork
On Sun, Apr 10, 2011 at 07:36:49AM +0000, Jonathan Nieder wrote:
> From: Jilles Tjoelker <jilles@stack.nl>
> Date: Sat, 13 Jun 2009 16:17:45 -0500
>
> This change only affects strings passed to -c, when the -s option is
> not used.
>
> Use the EV_EXIT flag to inform the eval machinery that the string
> being passed is the entirety of input. This way, a fork may be
> omitted in many special cases.
>
> If there are empty lines after the last command, the evalcmd will not
> see the end early enough and forks will not be omitted. The same thing
> seems to happen in bash.
>
> Example:
> sh -c 'ps lT'
> No longer shows a shell process waiting for ps to finish.
>
> [jn: ported from FreeBSD SVN r194128. Bugs are mine.]
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Instead of detecting EOF using the input layer, I'm going to
use the parser instead. In either case, we always have to read
ahead in order to complete the parsing of the previous node.
Therefore we always know whether there is more to come, except
in the case where we see a newline/semicolon or similar.
For the purposes of sh -c, this should be sufficient.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function old new delta
evalstring 190 224 +34
ash_main 1014 1022 +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0) Total: 42 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-signals/signal3.right')
0 files changed, 0 insertions, 0 deletions