From caee80cd3da65670a576e610044fdc5e7c957d6d Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Tue, 25 Oct 2016 20:49:53 +0200
Subject: ash: [SHELL] Move flushall to the point just before _exit

Upstream commit:

    We need to flush at the very end in case we've generated any errors
    before that.  The flushall call cannot perform a longjmp so it's
    safe there.

    Date: Sat, 22 Sep 2007 20:50:21 +0800
    [SHELL] Move flushall to the point just before _exit

    We need to flush at the very end in case we've generated any errors
    before that.  The flushall call cannot perform a longjmp so it's
    safe there.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 shell/ash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'shell')

diff --git a/shell/ash.c b/shell/ash.c
index b7f20ba36..3f1405d81 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13187,12 +13187,12 @@ exitshell(void)
 		evalstring(p, 0);
 		/*free(p); - we'll exit soon */
 	}
-	flush_stdout_stderr();
  out:
 	/* dash wraps setjobctl(0) in "if (setjmp(loc.loc) == 0) {...}".
 	 * our setjobctl(0) does not panic if tcsetpgrp fails inside it.
 	 */
 	setjobctl(0);
+	flush_stdout_stderr();
 	_exit(status);
 	/* NOTREACHED */
 }
-- 
cgit v1.2.3-55-g6feb