pthread_exit() does not call the cleanups
Kereszt@crossys.com
Kereszt@crossys.com
Fri Nov 12 17:01:00 GMT 2004
Sorry.. here it is.
Thanks
> Well, but the attachment is missing...
>
> Regards
> Peter Slacik
>
> Kereszt@crossys.com wrote:
>
> >Hello,
> >
> >I've found that with pthread-win32 the pthread_exit() does not call the
> >previously pushed (pthread_cleanup_push()) cleanup routines. I've just
> >tried
> >it on a linux box and it works as documented (does the call).
> >
> >I'm a bit newbie to pthread so it might be my fault. I've attached a little
> >sample code which reproduces the problem.
> >
> >Please, tell me what's the deal!
> >
> >Thanks,
> >Laszlo
> >
> >
--
-------------- next part --------------
#ifdef _WIN32
# include <Windows.h>
#else
# include <unistd.h>
#endif
#include <stdio.h>
#include "pthread.h"
void cleanup (void *p)
{
fprintf (stderr, "cleanup\n");
}
void *t (void *)
{
pthread_cleanup_push (cleanup, NULL);
for (int i = 0; i < 5; i++) {
fprintf (stderr, "do...\n");
#ifdef _WIN32
Sleep (1000);
#else
sleep (1);
#endif
pthread_exit (NULL);
}
pthread_cleanup_pop (1);
return NULL;
}
int main ()
{ pthread_t t1;
pthread_create (&t1, NULL, t, NULL);
pthread_join (t1, NULL);
fprintf (stderr, "return\n");
getchar ();
return 0;
}
More information about the Pthreads-win32
mailing list