Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Nov 2011 16:57:50 GMT
From:      Yui NARUSE <naruse@airemix.jp>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/162379: When select(2) closed writing pipe, it will sticks.
Message-ID:  <201111081657.pA8GvoNR046708@red.freebsd.org>
Resent-Message-ID: <201111081700.pA8H0P5c070581@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help


>Number:         162379
>Category:       kern
>Synopsis:       When select(2) closed writing pipe, it will sticks.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 08 17:00:25 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Yui NARUSE
>Release:        FreeBSD 8.2
>Organization:
>Environment:
FreeBSD freebsd82-64 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
When select(2) closed writing pipe, it will sticks.

FreeBSD 9.0-RC1 also reproduces this.
>How-To-Repeat:
Run following program, it will sticks.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/select.h>
#define max(x,y) ((x > y) ? x : y)
int
main(void) {
    int pipes[2];
    int res = pipe(pipes);
    if (res != 0) abort();
    int r = pipes[0];
    int w = pipes[1];
    res = close(w);
    if (res != 0) abort();
    fd_set readfds; FD_ZERO(&readfds);
    fd_set writefds; FD_ZERO(&writefds);
    fd_set exceptfds; FD_ZERO(&exceptfds);
    FD_SET(w, &writefds);
    res = select(max(r,w)+1, &readfds, &writefds, &exceptfds, NULL);
    if (res) perror("select");
    return 0;
}
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111081657.pA8GvoNR046708>