Paul Eggert wrote:
> >> In this patch I did not add a FIXME for sigpipe-die; instead, I added a
> >> comment saying that install_sigpipe_die_handler should be called only in
> >> a single-threaded process
> > 
> > Actually, the restriction can be relaxed: It is OK to call
> > install_sigpipe_die_handler in a multithreaded program, at a moment
> > when the main thread is still the only thread.
> 
> Doesn't that tighten the restriction rather than relax it? The function 
> is safe whenever a process is single-threaded, regardless of whether the 
> process was formerly multithreaded.

It seems we have different definitions of "single-threaded process" /
"multi-threaded process".
Mine is: A process is single-threaded if the main thread is the only thread
across the entire process' lifetime; i.e. no other thread gets created.
Yours appears to be dependent on a time point.
I've never heard the concept of "formerly multithreaded".

Moreover, I try to think about a _program_ as being multithreaded or
single-threaded. For instance, GNU sort is multithreaded, because it
_may_ create threads, depending on circumstances.

> And (though this is pretty obscure) 
> the function need not be called from the main thread.

I wanted to explain the typical use of this function. The possibility
of the main thread creating a 2nd thread, then exiting, and the 2nd thread
then calling various initialization functions is quite theoretical.
It is a possibility, but it would be confusing to mention it.

Bruno




Reply via email to