This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC] signal-safe fprintf?
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.