Bug 59272 - pthread_create() causes "Interrupted system call"
Summary: pthread_create() causes "Interrupted system call"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 7.2
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-02-04 14:36 UTC by Wagner T. Correa
Modified: 2016-11-24 15:22 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-02-04 14:36:19 UTC
Embargoed:


Attachments (Terms of Use)

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.


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