Newsgroups: comp.os.parix
From: joep@fwi.uva.nl (Joep Vesseur)
Subject: Re: main thread termination
Organization: FWI, University of Amsterdam
Date: 21 Sep 1995 00:16:36 +0200
Message-ID: <43q3s4$ehg@mail.fwi.uva.nl>

nunov@pandora.uc.pt writes:
>Is it possible to a thread to know if/when the main
>function has terminated?

AFAIK: No

Either up/down some semaphore/mutex before main exits,
or create an extra thread that functions as the main thread, while
storing the Thread-id, so you can use WaitThread() later on.
Eg. something like

  Thread_t *main_id;
  ...
  main()
  {
    main_id = CreateThread(NULL, 0, main2, &err, NULL);
    exit(0);
  }

  Joep

