aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c8
1 files changed, 7 insertions, 1 deletions
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)
1418static void hush_exit(int exitcode) NORETURN; 1418static void hush_exit(int exitcode) NORETURN;
1419static void hush_exit(int exitcode) 1419static 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;