[RFA]: fork safe stdio locks

Jeff Johnston jjohnstn@redhat.com
Tue Mar 9 22:19:00 GMT 2004


Patch checked in with slight modification.  I changed the __fp_lock() and
__fp_unlock() routines to use _flockfile() and _funlockfile().

-- Jeff J.

Thomas Pfaff wrote:
> As i already mentioned i think that stdio locks should be locked at fork 
> and unlocked in both the parent and the child afterwards to avoid a 
> deadlock in the child process (at least when you are working with 
> pthread mutexes for locking).
> 
> The attached patch will add 2 functions to findfp.c which can be called 
> at before and after fork.
> 
> Thomas
> 
> 2004-03-08  Thomas Pfaff  <tpfaff@gmx.net>
> 
>     * libc/stdio/findfp.c (__sfp): Rename lock to __sfp_lock.
>     Change __sfp_lock to static global.
>     (__fp_lock): New static function.
>     (__fp_unlock): Ditto.
>     (__fp_lock_all): New function.
>     (__fp_unlock_all): Ditto.



More information about the Newlib mailing list