[RFC] signal-safe fprintf?
Andrew Hunter
ahh@google.com
Thu Mar 7 17:09:00 GMT 2013
On Thu, Mar 7, 2013 at 1:40 AM, Siddhesh Poyarekar
<siddhesh.poyarekar@gmail.com> wrote:
> Right, mmap is not guaranteed by the standard to be signal safe
> either, but it tends to work in practice compared to malloc.
>
Agree here, though I'd vote for keeping it as if (buf) munmap(buf) on
the back end. I'd be very happy if we switched to mmap.
> In fact, I just had a quick look at the vfprintf code and I think the
> malloc is not the only problem you'll have to work around. The
> vfprintf code locks the FILE, which can cause a deadlock if a signal
> handler was called with that lock held.
>
This is true, but as pointed out downthread snprintf is (I think) not
vulnerable to this, though I could be misinterpreting how the
fake-files work.
More information about the Libc-alpha
mailing list