From: millert Date: Sat, 22 Jan 2022 23:22:11 +0000 (+0000) Subject: Flush all stdio streams before running a shell command. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1f6b1162831e58a00b1b5c51ff98c49d2d91634b;p=openbsd 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@ --- 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;