Date: Wed, 9 Jul 2003 22:47:10 -0400 (EDT) From: Daniel Eischen <eischen@vigrid.com> To: Brooks Davis <brooks@one-eyed-alien.net> Cc: freebsd-threads@freebsd.org Subject: Re: null pthread_t Message-ID: <Pine.GSO.4.10.10307092242350.9055-100000@pcnet5.pcnet.com> In-Reply-To: <20030710001744.GA7135@Odin.AC.HMC.Edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Jul 2003, Brooks Davis wrote: > I've got some Linux pthread code that goes something like this that I'm > porting to FreeBSD: > > ------ > pthread_t tid; > > tid = -1; > > /* Do stuff including maybe creating a thread. */ > > if (tid != -1) { > pthread_cancel(tid); > pthread_join(tid, NULL); > } > ------ > > Since FreeBSD uses pointers instead of integers for pthread_t's, this > generates warnings which go away if you replace -1 with NULL, but > it seems like that is likely to do bad things on linux. Is there a > portable NULL-equivalent pthread_t? I'm not seeing anything jump out at > me in the headers. The code in question shouldn't be doing that. If it needs to know whether a thread id is valid, it should have a separate flag for it (tid_valid) or possibly use pthread_kill(tid, 0) and checking the return value (sending signal 0 to a thread is akin to sending a process signal 0; the signal isn't delivered but the process id is checked for validity). -- Dan Eischen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10307092242350.9055-100000>