tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: patch adding a pidfile-option to script(1)



> Date: Wed, 16 Sep 2026 22:35:16 +0700
> From: Robert Elz <kre%munnari.OZ.AU@localhost>
> 
>     Date:        Wed, 16 Sep 2026 16:52:27 +0200
>     From:        Timo Buhrmester <timo%math.uni-bonn.de@localhost>
>     Message-ID:  <aqqtKwMae0ge2_o8%math.uni-bonn.de@localhost>
> 
>   | 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.


Home | Main Index | Thread Index | Old Index