...
Section 2.9.1 of the System Interfaces volume of POSIX.1-2008 has a much longer list of functions that are not required to be thread - safe.
Non-Compliant Code Example
...
The compliant solution uses strerror_r()
, which has the same functionality as strerror()
but guarantees thread - safety.
Code Block | ||
---|---|---|
| ||
FILE* fd = fopen( filename, "r"); if (fd == NULL) { char errmsg[BUFSIZ]; if (strerror_r( errno, errmsg, BUFSIZ) != 0) { /* handle error */ } printf("Could not open file because of %s\n", errmsg); } |
...