program hangs in exit()
Saurabh Desai <[email protected]>
| Newsgroups | gmane.comp.lib.phil |
|---|---|
| Message-ID | <[email protected]> |
The following program hangs during final exit()
using NPTL on RH9. It works using Linuxthreads.
The fgets() blocks while holding stdin->_lock and
during exit(), _IO_cleanup() also tries to acquire
same lock. Under Linuxthreads, the pthread_handle_exit()
calls __fresetlockfiles() which resets all file locks.
This is missing under NPTL.
- Saurabh
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
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");
}