Bug 59272

Summary: pthread_create() causes "Interrupted system call"
Product: [Retired] Red Hat Linux Reporter: Wagner T. Correa <wtcorrea>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: fweimer, wtcorrea
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-02-04 14:36:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Wagner T. Correa 2002-02-04 14:36:15 UTC
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:

Comment 1 Jakub Jelinek 2002-02-04 14:47:37 UTC
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.