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

Re: program hangs in exit()

Saurabh Desai wrote:
The following program hangs during final exit()
using NPTL on RH9. It works using Linuxthreads. ...

void *th_routine(void *arg)
        char buf[128];

        fgets(buf, sizeof(buf), stdin);
        return NULL;

main(int ac, char **av)
        pthread_t th;
        int rc;

        if ((rc = pthread_create(&th, NULL, th_routine, (void *)NULL)))
            printf("pthread_create failed, rc=%d\n", rc);
        printf("main: about to exit\n");

Oddly, I can't tell from SuSv3 what is supposed to happen here. The standard says returning from main is the same as calling exit, exit says it closes all files, but read doesn't say the I/O will be interrupted if some other thread closes the file while the read is blocked. The new behavior, even if it's a bug, might in fact comply with SuSv3.

I'm interested to hear what Ulrich has to say.
- Dan

Dan Kegel

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