@@ -157,7 +157,7 @@ main(int argc, char *argv[])
157
157
if (rc != 0 )
158
158
{
159
159
fprintf (stderr ,"Failed to create thread 1: %s **\nexiting\n" ,
160
- strerror (rc ));
160
+ strerror (errno ));
161
161
exit (1 );
162
162
}
163
163
rc = pthread_create (& thread2 ,NULL , (void * (* ) (void * ))func_call_2 ,NULL );
@@ -285,6 +285,11 @@ func_call_1(void)
285
285
/* Set errno = EEXIST */
286
286
287
287
/* create, then try to fail on exclusive create open */
288
+ /*
289
+ * It would be great to check errno here but if errno is not thread-safe
290
+ * we might get a value from the other thread and mis-report the cause
291
+ * of the failure.
292
+ */
288
293
#ifdef WIN32
289
294
if ((h1 = CreateFile (TEMP_FILENAME_1 ,GENERIC_WRITE ,0 ,NULL ,OPEN_ALWAYS ,0 ,NULL ))==
290
295
INVALID_HANDLE_VALUE )
@@ -299,7 +304,7 @@ func_call_1(void)
299
304
300
305
#ifdef WIN32
301
306
if (CreateFile (TEMP_FILENAME_1 ,GENERIC_WRITE ,0 ,NULL ,CREATE_NEW ,0 ,NULL )
302
- != INVALID_HANDLE_VALUE || GetLastError () != ERROR_FILE_EXISTS )
307
+ != INVALID_HANDLE_VALUE )
303
308
#else
304
309
if (open (TEMP_FILENAME_1 ,O_RDWR |O_CREAT |O_EXCL ,0600 ) >=0 )
305
310
#endif