On 2026-04-04 15:26, Bruno Haible wrote:

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".

I'm using POSIX's simpler definition: a single-threaded process has one thread, and a multithreaded process has more than one thread. See:

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_213
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_339

When there's little point to diverging (as is the case here), it's better to stick with the POSIX terminology.


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.

Yes, that's the usual distinction between process and program, and by "multi-threaded program" POSIX means the program has been linked with a library that lets it create threads via pthread_create etc. which means its processes might be multithreaded or single-threaded, whereas a "single-threaded program" cannot do that and so its processes must be single-threaded. This corresponds closely with your notion of multithreaded program, and this definition is fine. See:

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_214
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_340



It is a possibility, but it would be confusing to mention it.

We don't need to mention that possibility explicitly; all we need to do is use the correct POSIX terminology.

That is, the install_sigpipe_die_handler comment should say simply "This function should not be called in a multithreaded process."

The current comment's wording "In a multithreaded program, this function must be called in the main thread, before any other thread gets created" is (a) more complicated, (b) restricts the caller unnecessarily, and (c) confused me, as I was coming from the POSIX threading model and could not figure out why there was that extra restriction above and beyond the obvious one.

Reply via email to