From c9302c5f1b9a358db53ce79123bc62dff49c4205 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 30 Apr 2015 18:07:48 +0000 Subject: [PATCH] MFC r281617: wc: Fix SIGINFO race causing final results to be lost to stderr. Relnotes: yes --- usr.bin/wc/wc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index 08823a132b69..156a3270c018 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -74,6 +74,14 @@ siginfo_handler(int sig __unused) siginfo = 1; } +static void +reset_siginfo(void) +{ + + signal(SIGINFO, SIG_DFL); + siginfo = 0; +} + int main(int argc, char *argv[]) { @@ -207,6 +215,7 @@ cnt(const char *file) } else tmpll++; } + reset_siginfo(); tlinect += linect; if (dochar) tcharct += charct; @@ -229,6 +238,7 @@ cnt(const char *file) return (1); } if (S_ISREG(sb.st_mode)) { + reset_siginfo(); charct = sb.st_size; show_cnt(file, linect, wordct, charct, llct); tcharct += charct; @@ -289,6 +299,7 @@ word: gotsp = 1; } } } + reset_siginfo(); if (domulti && MB_CUR_MAX > 1) if (mbrtowc(NULL, NULL, 0, &mbs) == (size_t)-1 && !warned) warn("%s", file != NULL ? file : "stdin");