| Summary: | select returns 0 on receipt of SIGALRM when linked with pthreads. | ||
|---|---|---|---|
| Product: | Base System | Reporter: | jogibson <jogibson> |
| Component: | misc | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.0-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Fixed in both -stable and -current. |
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)); }