mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 17:52:43 +00:00
MFC r281617:
wc: Fix SIGINFO race causing final results to be lost to stderr. Relnotes: yes
This commit is contained in:
parent
cb784c9f28
commit
c9302c5f1b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=282278
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user