Re: Gtk+ print support - request for feedback

> The man page for setlocale() says nothing about thread safety, but
> given how all of the other standard C calls work I'm frankly shocked
> that setting the locale in one thread affects the others.  Is this
> just a bug on Linux, or is it a general problem on other operating
> systems?

Solaris' man page says...

     To change locale in a multithreaded application, setlocale()
     should  be  called  prior to using any locale-sensitive rou-
     tine.  Using setlocale() to query the current locale is safe
     and can be used anywhere in a multithreaded application.

Note, that the effect is not just that the other thread might see
a locale changed.  Pointers they got from localeconv or setlocale
might turn invalid underneath them.  Or code they were running
might be unmapped.  (After all, shared libraries uses as plugins
are a common way of dealing with locales.)

The unfortunate effect is that sscanf is not going to be useful
for a library.  Unless you are willing to fork() but that comes
with its own set of problems.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]