public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* pthread_exit() does not call the cleanups
@ 2004-11-12 16:51 Kereszt
       [not found] ` <4194EB9F.6050002@tatramed.sk>
  0 siblings, 1 reply; 3+ messages in thread
From: Kereszt @ 2004-11-12 16:51 UTC (permalink / raw)
  To: pthreads-win32


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pthread_exit() does not call the cleanups
       [not found] ` <4194EB9F.6050002@tatramed.sk>
@ 2004-11-12 17:01   ` Kereszt
  2004-11-12 19:29     ` Kereszt
  0 siblings, 1 reply; 3+ messages in thread
From: Kereszt @ 2004-11-12 17:01 UTC (permalink / raw)
  To: pthreads-win32

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]


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
> > 
> >

-- 

[-- Attachment #2: test.cpp --]
[-- Type: text/plain, Size: 572 bytes --]

#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;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pthread_exit() does not call the cleanups
  2004-11-12 17:01   ` Kereszt
@ 2004-11-12 19:29     ` Kereszt
  0 siblings, 0 replies; 3+ messages in thread
From: Kereszt @ 2004-11-12 19:29 UTC (permalink / raw)
  To: pthreads-win32


My fault. False alarm.

At some point I failed to define __CLEANUP_CXX, and pthreadVSE doesn't work
fine with C++ exceptions enabled (VC++ compiler option: /GX or /EHsc). MSDN
says it can be mixed.. mostly.. but.. Unfortunately, the latest pthread
release doesn't contain precompiled VCE binary.. I tried it from the
previous (2004-06-22) release. Finally, I successfully compiled a fresh one
with VS7. I am simply unable to get work nmake, some PATH or whatever seems
to be missing but I cant hunt forever. I'm from UNIX.. it looks much cleaner
for me..

Conclusion: Now, it works.. Maybe, this will help others browsing mail
archives :)

Thanks and best regards,
Laszlo


> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-12 19:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-12 16:51 pthread_exit() does not call the cleanups Kereszt
     [not found] ` <4194EB9F.6050002@tatramed.sk>
2004-11-12 17:01   ` Kereszt
2004-11-12 19:29     ` Kereszt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).