Document: WG14 N1462

errno and threads

Submitter: Fred J. Tydeman (USA)
Submission Date: 2010-05-10
Related documents: N1416, N1427
Subject: errno at thread create


Add a new paragraph to 7.5 Errors <errno.h>

There is a distinct errno per thread 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.

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.