Date: Fri, 10 Nov 2000 15:16:34 -0800 (PST) From: jogibson@cisco.com To: freebsd-gnats-submit@FreeBSD.org Subject: misc/22758: select returns 0 on receipt of SIGALRM when linked with pthreads. Message-ID: <20001110231634.AAD0737B479@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 22758
>Category: misc
>Synopsis: select returns 0 on receipt of SIGALRM when linked with pthreads.
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Nov 10 15:20:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: John Gibson
>Release: 4.0-STABLE, 4.1.1-STABLE
>Organization:
Cisco Systems
>Environment:
FreeBSD 4.1.1-STABLE FreeBSD 4.1.1-STABLE #0: Mon Oct 30 07:47:02 EST 2000 i386
>Description:
On receipt of a SIGALRM, select will return 0 when linked to the
reentrant C library libc_r (for pthreads) and not set errno to EINTR.
When linked to libc (no pthreads) select returns -1 and sets errno
to EINTR.
>How-To-Repeat:
/*
* testsel.c
* On receipt of SIGALRM, select() returns:
* 0 when linked with libc_r
* -1 otherwise.
*
* Tp compile with threads...
* cc -o testsel testsel.c -pthread
*
* To compile without threads...
* cc -o testsel testsel.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
handle_sigalarm(void)
{
fprintf(stderr,"ALARM!\n");
}
int
main(void)
{
struct sigaction sact;
fd_set fds;
int error;
sact.sa_flags = 1;
sact.sa_handler = (sig_t) handle_sigalarm;
sigaction(SIGALRM, &sact, NULL);
FD_ZERO(&fds);
alarm(1);
fprintf(stderr, "test: calling select...\n");
error = select(0, &fds, 0, 0, 0);
fprintf(stderr, "test: select returned %d\n", error);
if (errno == EINTR)
fprintf(stderr, "test: errno=EINTR\n");
else
fprintf(stderr, "test: errno!=EINTR (error: %s)\n", strerror(errno));
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001110231634.AAD0737B479>
