Document: WG14 N1427
Submitter: Fred J. Tydeman (USA)
Submission Date: 2009-11-22
Related documents: N1416
Subject: errno at thread create
Add a new paragraph to 7.5 Errors <errno.h>
There is a distinct errno per thread [footnote] and use of errno in an expression refers to the errno associated with the thread evaluating the expression. The initial state for a thread's errno (other than for main()) is an indeterminate value.
[footnote] While errno has, at least, thread storage duration, it need not be part of thread local storage.
Add to the Rationale section on errno:
Having one global errno would result in confusion as library routines in multiple threads could be altering it at the "same" time to indicate different errors. Therefore, each thread has its own errno.
Some, but not all, existing implementations have errno be part of thread local storage.