public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Savatier <tristan@mpegtv.com>
To: Milan Gardian <mg@tatramed.sk>
Cc: pthreads-win32@sourceware.cygnus.com
Subject: Re: [pthread-win32] RE: pthread_exit bug ?
Date: Thu, 02 Sep 1999 04:10:00 -0000	[thread overview]
Message-ID: <37CE5D09.CB956A54@mpegtv.com> (raw)
In-Reply-To: <000301bef52e$f59e5e10$440b10ac@leibinger.freinet.de>

Milan Gardian wrote:
> 
> [snip]
> > My program creates several threads.  At termination,
> > each thread (except the main thread) terminates by calling
> > pthread_exit, then the main thread terminates by
> > calling pthread_exit (at this point, all my threads
> > are terminated, therefore the process should disapear).
> 
> (This note does not try to diminish the meaning of the reported bug)
> Q: Is there a reason to use pthread_exit from the main thread? A special
> functionality prehaps? Specifically, I would like to know if there's some
> difference between these two code snips:
> 
> (a)
> int main(void)
> {
>     //Do some threading stuff...
>     return (24);
> }
> 
> (b)
> void main(void)
> {
>     //Do some threading stuff...
>     pthread_exit(24);
> }

Note also another big difference between those two cases,
according to my book:

When main() "falls off the bottom" i.e. returns,
the main thread makes an implicit call to exit(),
also killing the process.

When any other thread "falls off the bottom" of its
initial function, it implicitely calls pthread_exit()
exiting only that one thrad.

In the special case where the main thread calls pthread_exit(),
that thread exits but does NOT call exit(), and the
process continues.

Finally, if all the [main and user-created] threads exit,
the thread library will detect that and call exit() itself
to terminate the process.

-t

      parent reply	other threads:[~1999-09-02  4:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-17 19:44 gcc mingw/crtdll patch Bossom, John
1999-08-18  4:45 ` Return values Milan Gardian
1999-08-18 21:31   ` Ross Johnson
1999-09-02  2:43   ` pthread_exit bug ? Tristan Savatier
1999-09-02  3:06     ` Peter Slacik
1999-09-02  3:22     ` Ross Johnson
1999-09-02  3:35     ` Milan Gardian
1999-09-02  3:47       ` [pthread-win32] " Tristan Savatier
1999-09-02  4:10       ` Tristan Savatier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37CE5D09.CB956A54@mpegtv.com \
    --to=tristan@mpegtv.com \
    --cc=mg@tatramed.sk \
    --cc=pthreads-win32@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).