From d0bf8b5aaccbe082d3728279620b8f8474d9ca8a Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 18 Feb 2024 10:55:11 -0800 Subject: [PATCH] wc: Fix SIGINFO race with casper init. If a file is specified then fileargs_init(3) may return [EINTR]. With the SIGINFO handler not being SA_RESTART this causes an early exit if a SIGINFO comes in. Rather than checking for [EINTR] or changing the handler just move it later which resolves the problem. --- usr.bin/wc/wc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index 76b65e5f870..4e8a2d8a8b5 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -117,8 +117,6 @@ main(int argc, char *argv[]) argv += optind; argc -= optind; - (void)signal(SIGINFO, siginfo_handler); - fa = fileargs_init(argc, argv, O_RDONLY, 0, cap_rights_init(&rights, CAP_READ, CAP_FSTAT), FA_OPEN); if (fa == NULL) @@ -137,6 +135,7 @@ main(int argc, char *argv[]) xo_open_container("wc"); xo_open_list("file"); + (void)signal(SIGINFO, siginfo_handler); errors = 0; total = 0; if (argc == 0) {