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)
>> [...] 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).
> 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.
That makes it safe...for one particular implementation. It is not safe
in general. There is no promise that stdio is signal-unsafe only when
the signal interrupts a stdio call, though that is the way most
implementations happen to work.
Of course, NetBSD does lots of things that are not safe in general (for
example, the 9.1 getaddrinfo(3) manpage does a memset to 0 on a struct
containing pointers in its EXAMPLES). What you suggest might be safe
enough.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index