The branch main has been updated by bdrewery:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d0bf8b5aaccbe082d3728279620b8f8474d9ca8a

commit d0bf8b5aaccbe082d3728279620b8f8474d9ca8a
Author:     Bryan Drewery <bdrew...@freebsd.org>
AuthorDate: 2024-02-18 18:55:11 +0000
Commit:     Bryan Drewery <bdrew...@freebsd.org>
CommitDate: 2024-02-18 18:57:42 +0000

    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 76b65e5f870d..4e8a2d8a8b59 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) {

Reply via email to