summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2022-01-22 23:22:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2022-01-22 23:22:12 +0000
commitec826ed21713fb72bf41a9715d0dd380a989aba4 (patch)
tree40a635ef9fd5efbd7c5d4bf1b5f7133b10115300 /bin
parent60edf4d4e6b79712e3b597d388e23b03efe2497b (diff)
Flush all stdio streams before running a shell command.
Otherwise, if ed's output is not line buffered (e.g. if it is redirected to a file or pipe) the shell command output may be displayed before data buffered by ed itself is written. From Soeren Tempel. OK deraadt@
Diffstat (limited to 'bin')
-rw-r--r--bin/ed/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/ed/main.c b/bin/ed/main.c
index dc73dd92b69..231d021ef19 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.66 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.67 2022/01/22 23:22:11 millert Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
/* main.c: This file contains the main control and user-interface routines
@@ -852,6 +852,7 @@ exec_command(void)
return ERR;
GET_COMMAND_SUFFIX();
if (sflags) printf("%s\n", shcmd + 1);
+ fflush(NULL); /* flush any buffered I/O */
system(shcmd + 1);
if (!scripted) printf("!\n");
break;