diff options
author | 2020-07-20 18:55:15 +0000 | |
---|---|---|
committer | 2020-07-20 18:55:15 +0000 | |
commit | 8bde13738c2116ba011febdc71df0153fef3c345 (patch) | |
tree | eb232d850642ff9d5c5b5b27c5d82b2ff092517f /usr.bin | |
parent | cleanup ttrstrt; no functional change; ok dlg (diff) | |
download | wireguard-openbsd-8bde13738c2116ba011febdc71df0153fef3c345.tar.xz wireguard-openbsd-8bde13738c2116ba011febdc71df0153fef3c345.zip |
In closeall(), skip stdin and flush std{err,out} instead of closing.
Otherwise awk could fclose(stdin) twice (it may appear more than once)
and closing stderr means awk cannot report errors closing other streams.
OK tim@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/awk/run.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index 4ba6c79eac1..a826182672e 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.63 2020/07/02 19:06:22 millert Exp $ */ +/* $OpenBSD: run.c,v 1.64 2020/07/20 18:55:15 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -1977,8 +1977,12 @@ void closeall(void) continue; if (ferror(files[i].fp)) FATAL( "i/o error occurred on %s", files[i].fname ); + if (files[i].fp == stdin) + continue; if (files[i].mode == '|' || files[i].mode == LE) stat = pclose(files[i].fp) == -1; + else if (files[i].fp == stdout || files[i].fp == stderr) + stat = fflush(files[i].fp) == EOF; else stat = fclose(files[i].fp) == EOF; if (stat) |