Skip to content

Avoid a fork before running last command given to -c

Jonathan Nieder dash 1 version In review

Get series with b4
b4 am 20110410071734.GA16736@elie

Versions newest first

  1. v1 Latest4 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4Introduce preadateof predicate to check for end of inputsrc/input.c src/input.h+18 -00 replies
2/4Make eval flags publicsrc/eval.c+0 -40 replies
3/4Take advantage of EV_EXIT in evalstringsrc/eval.c+4 -10 replies
4/4Optimize dash -c "command" to avoid a forksrc/main.c+1 -18 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH/RFC dash 0/4] Avoid a fork before running last command given to -c

Hi,

Jilles Tjoelker wrote[0]:

Quoted 3 lines

Regarding sh -c optimization, I am in favour of this. Uselessly waiting 'sh -c' processes annoy me. I made the change for FreeBSD 8.0 sh, which is very similar to dash. The SVN changeset is r194128.

So I grabbed that changeset with

	svn log -v svn://svn.freebsd.org/base/head/bin/sh -r 194128
	svn diff -r 194127:194128 svn://svn.freebsd.org/base/head/bin/sh

and made it a tiny bit smaller. Here's the result.

   text    data     bss     dec     hex filename
  83994    1784   11128   96906   17a8a dash.before-O2
  83994    1784   11128   96906   17a8a dash.before-Os
  84146    1784   11128   97058   17b22 dash.after-O2
  84146    1784   11128   97058   17b22 dash.after-Os

On this amd64 the cost is 152 bytes of text. Thoughts?

[0] http://bugs.debian.org/436466

Jilles Tjoelker (4):
[INPUT] Introduce preadateof predicate to check for end of input [EVAL] Make eval flags public
[EVAL] Take advantage of EV_EXIT in evalstring
[MAIN] Optimize dash -c "command" to avoid a fork

 src/eval.c  |   11 +++++------
 src/eval.h  |    5 +++++
 src/input.c |   17 +++++++++++++++++
 src/input.h |    1 +
 src/main.c  |    2 +-
 5 files changed, 29 insertions(+), 7 deletions(-)