From Bugzilla Helper: User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.9-21 i686) Description of problem: There seems to be a bug in pthread_create(). Whenever I call it, I get the error "Interrupted system call." The following program shows the problem. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Compile and run the program below. #include <assert.h> #include <errno.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> void *foo(void *arg) { while (1) { } return NULL; } int main(void) { int status; pthread_t t; status = pthread_create(&t, NULL, foo, NULL); if (status != 0) { fprintf(stderr, "create failed\n"); perror(NULL); exit(1); } if (errno != 0) { fprintf(stderr, "non-zero errno\n"); perror(NULL); exit(1); } return 0; } Actual Results: The program will abort because errno is non-zero. Expected Results: Since pthread_create() returns 0, I would expect errno to be also 0. Additional info:
Wrong expectation, see http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_create.html pthread_create returns error code in its return value, not in errno. Generally, errno value is undefined unless immediately after function call which is documented to modify errno and which returned -1, or in just a few specific cases documented in the standards (e.g. strto*l). errno = 0; read(...); if (errno != 0) { } is a wrong thing to do as well, errno is defined only if read returns -1.