> Date: Wed, 16 Sep 2026 22:35:16 +0700 > From: Robert Elz <[email protected]> > > Date: Wed, 16 Sep 2026 16:52:27 +0200 > From: Timo Buhrmester <[email protected]> > Message-ID: <[email protected]> > > | I'm not asking for this to be merged into NetBSD, but I also wouldn't > | mind. Maybe somebody finds it useful. > > It wouldn't be merged as is anyway - the -P option by itself is > harmless, but the way the SIGUSR1 handling is coded won't work in > general - signal handlers should only ever call async signal safe > functions, and neither fopen() nor fclose() is that (fflush() I'm > not sure about). > > Signal handlers generally (if they don't just do somemething simple) > need to just set a flag, and then have the mainline code test for > that flag being set, and do the work then - at a time it is safe > (and desirable) for that to happen.
This patch can be made safe with a much smaller modification: simply keep SIGUSR1 blocked _except_ during the calls to read() and write() in dooutput(), when there is no risk of interrupting access to the stdio data structures. Just needs a handful of sigprocmask calls.
