[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);
            exit(1);
        }
        sleep(1);
        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
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045




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