Bug 59272 - pthread_create() causes "Interrupted system call"
pthread_create() causes "Interrupted system call"
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-02-04 09:36 EST by Wagner T. Correa
Modified: 2007-04-18 12:39 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-02-04 09:36:19 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Wagner T. Correa 2002-02-04 09:36:15 EST
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:

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");
	if (errno != 0) {
		fprintf(stderr, "non-zero errno\n");
	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:
Comment 1 Jakub Jelinek 2002-02-04 09:47:37 EST
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.

Note You need to log in before you can comment on or make changes to this bug.