diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-07 02:03:51 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-07 02:03:51 +0100 |
commit | 8ee2adab21328761b80e0cbc513eda7eaa880b24 (patch) | |
tree | c771696ab3b1be735e831b1721ab751c874e1cd3 /shell | |
parent | b8ab4b038803df195eee9844c3597dd640c00393 (diff) | |
download | busybox-w32-8ee2adab21328761b80e0cbc513eda7eaa880b24.tar.gz busybox-w32-8ee2adab21328761b80e0cbc513eda7eaa880b24.tar.bz2 busybox-w32-8ee2adab21328761b80e0cbc513eda7eaa880b24.zip |
echo: do not retry on write errors
function old new delta
echo_main 297 336 +39
stpcpy - 22 +22
run_pipe 1561 1566 +5
pseudo_exec_argv 187 192 +5
hush_exit 75 80 +5
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 98/0) Total: 76 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash_test/ash-misc/echo_write_error.right | 2 | ||||
-rw-r--r-- | shell/ash_test/ash-misc/echo_write_error.tests | 7 | ||||
-rw-r--r-- | shell/ash_test/ash-redir/redir.right | 1 | ||||
-rw-r--r-- | shell/hush.c | 8 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/echo_write_error.right | 2 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/echo_write_error.tests | 7 |
6 files changed, 26 insertions, 1 deletions
diff --git a/shell/ash_test/ash-misc/echo_write_error.right b/shell/ash_test/ash-misc/echo_write_error.right new file mode 100644 index 000000000..3e91a13d3 --- /dev/null +++ b/shell/ash_test/ash-misc/echo_write_error.right | |||
@@ -0,0 +1,2 @@ | |||
1 | ash: write error: Broken pipe | ||
2 | Ok: 1 | ||
diff --git a/shell/ash_test/ash-misc/echo_write_error.tests b/shell/ash_test/ash-misc/echo_write_error.tests new file mode 100644 index 000000000..0a40c9ff7 --- /dev/null +++ b/shell/ash_test/ash-misc/echo_write_error.tests | |||
@@ -0,0 +1,7 @@ | |||
1 | trap "" PIPE | ||
2 | |||
3 | { | ||
4 | sleep 1 | ||
5 | echo Cant write this - get EPIPE | ||
6 | echo Ok: $? >&2 | ||
7 | } | { true; } | ||
diff --git a/shell/ash_test/ash-redir/redir.right b/shell/ash_test/ash-redir/redir.right index 2a02d41ce..c1a6e729a 100644 --- a/shell/ash_test/ash-redir/redir.right +++ b/shell/ash_test/ash-redir/redir.right | |||
@@ -1 +1,2 @@ | |||
1 | ash: write error: Bad file descriptor | ||
1 | TEST | 2 | TEST |
diff --git a/shell/hush.c b/shell/hush.c index 10788b8e7..e857e7464 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1418,6 +1418,7 @@ static void sigexit(int sig) | |||
1418 | static void hush_exit(int exitcode) NORETURN; | 1418 | static void hush_exit(int exitcode) NORETURN; |
1419 | static void hush_exit(int exitcode) | 1419 | static void hush_exit(int exitcode) |
1420 | { | 1420 | { |
1421 | fflush_all(); | ||
1421 | if (G.exiting <= 0 && G.traps && G.traps[0] && G.traps[0][0]) { | 1422 | if (G.exiting <= 0 && G.traps && G.traps[0] && G.traps[0][0]) { |
1422 | /* Prevent recursion: | 1423 | /* Prevent recursion: |
1423 | * trap "echo Hi; exit" EXIT; exit | 1424 | * trap "echo Hi; exit" EXIT; exit |
@@ -6105,10 +6106,13 @@ static void exec_builtin(char ***to_free, | |||
6105 | char **argv) | 6106 | char **argv) |
6106 | { | 6107 | { |
6107 | #if BB_MMU | 6108 | #if BB_MMU |
6108 | int rcode = x->b_function(argv); | 6109 | int rcode; |
6110 | fflush_all(); | ||
6111 | rcode = x->b_function(argv); | ||
6109 | fflush_all(); | 6112 | fflush_all(); |
6110 | _exit(rcode); | 6113 | _exit(rcode); |
6111 | #else | 6114 | #else |
6115 | fflush_all(); | ||
6112 | /* On NOMMU, we must never block! | 6116 | /* On NOMMU, we must never block! |
6113 | * Example: { sleep 99 | read line; } & echo Ok | 6117 | * Example: { sleep 99 | read line; } & echo Ok |
6114 | */ | 6118 | */ |
@@ -6832,6 +6836,7 @@ static NOINLINE int run_pipe(struct pipe *pi) | |||
6832 | if (!funcp) { | 6836 | if (!funcp) { |
6833 | debug_printf_exec(": builtin '%s' '%s'...\n", | 6837 | debug_printf_exec(": builtin '%s' '%s'...\n", |
6834 | x->b_cmd, argv_expanded[1]); | 6838 | x->b_cmd, argv_expanded[1]); |
6839 | fflush_all(); | ||
6835 | rcode = x->b_function(argv_expanded) & 0xff; | 6840 | rcode = x->b_function(argv_expanded) & 0xff; |
6836 | fflush_all(); | 6841 | fflush_all(); |
6837 | } | 6842 | } |
@@ -7641,6 +7646,7 @@ int hush_main(int argc, char **argv) | |||
7641 | G.global_argc -= builtin_argc; /* skip [BARGV...] "" */ | 7646 | G.global_argc -= builtin_argc; /* skip [BARGV...] "" */ |
7642 | G.global_argv += builtin_argc; | 7647 | G.global_argv += builtin_argc; |
7643 | G.global_argv[-1] = NULL; /* replace "" */ | 7648 | G.global_argv[-1] = NULL; /* replace "" */ |
7649 | fflush_all(); | ||
7644 | G.last_exitcode = x->b_function(argv + optind - 1); | 7650 | G.last_exitcode = x->b_function(argv + optind - 1); |
7645 | } | 7651 | } |
7646 | goto final_return; | 7652 | goto final_return; |
diff --git a/shell/hush_test/hush-misc/echo_write_error.right b/shell/hush_test/hush-misc/echo_write_error.right new file mode 100644 index 000000000..ddcad4363 --- /dev/null +++ b/shell/hush_test/hush-misc/echo_write_error.right | |||
@@ -0,0 +1,2 @@ | |||
1 | hush: write error: Broken pipe | ||
2 | Ok: 1 | ||
diff --git a/shell/hush_test/hush-misc/echo_write_error.tests b/shell/hush_test/hush-misc/echo_write_error.tests new file mode 100755 index 000000000..0a40c9ff7 --- /dev/null +++ b/shell/hush_test/hush-misc/echo_write_error.tests | |||
@@ -0,0 +1,7 @@ | |||
1 | trap "" PIPE | ||
2 | |||
3 | { | ||
4 | sleep 1 | ||
5 | echo Cant write this - get EPIPE | ||
6 | echo Ok: $? >&2 | ||
7 | } | { true; } | ||