[Bug 40852] select(2): document action of close()'ing a fd during a select()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.kernel.org/show_bug.cgi?id=40852


Michael Kerrisk <mtk.manpages@xxxxxxxxx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |mtk.manpages@xxxxxxxxx




--- Comment #1 from Michael Kerrisk <mtk.manpages@xxxxxxxxx>  2012-08-17 05:45:03 ---
Confirmed, with the program below.

#include <sys/time.h>
#include <pthread.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

#define errExit(msg)     do { perror(msg); exit(EXIT_FAILURE); \
            } while (0)

#define errExitEN(en, msg) \
                do { errno = en; perror(msg); \
                     exit(EXIT_FAILURE); } while (0)

static void *
threadFunc(void *arg)
{
    sleep(2);

    printf("Closing file descriptor\n");
    close(STDIN_FILENO);

    return NULL;
} /* threadFunc */

int
main(int argc, char *argv[])
{
    pthread_t t1;
    fd_set readfds;
    int ready, s;

    FD_ZERO(&readfds);
    FD_SET(STDIN_FILENO, &readfds);

    s = pthread_create(&t1, NULL, threadFunc, (void *) 1);
    if (s != 0)
    errExitEN(s, "pthread_create");

    printf("Main thread about to call select()\n");

    ready = select(STDIN_FILENO + 1, &readfds, NULL, NULL, NULL);
    if (ready == -1)
    errExit("select");

    s = pthread_join(t1, NULL);
    if (s != 0)
    errExitEN(s, "pthread_join");

    printf("Main thread exiting\n");

    exit(EXIT_SUCCESS);
}

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux