|
Boost : |
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2001-08-22 08:37:09
> When run this program never ends, illustrating your point about
> _endthreadex et. al. However, comment out the _endthreadex line and
> the program terminates immediately even though the documentation you
> quote above indicates that returning from a thread's entry routine
> automatically calls _endthreadex. In this regard the main thread is
> unique and the documentation simply doesn't cover the semantics.
yes. MS documentation fails to mention that main thread is special.
there is no implicit call to ExitThread/_endthread(ex) on return
from main function. it also fails to mention that ExitProcess/exit
is called implicitly on return from main function.
posix says:
"As required by the ISO C standard, using return from
main() has the same behavior (other than with respect
to language scope issues) as calling exit() with the
returned value. Reaching the end of the main() function
has the same behavior as calling exit(0)."
"Note that the thread in which main() was originally
invoked differs from this. When it returns from
main(), the effect shall be as if there was an
implicit call to exit() using the return value
of main() as the exit status."
"If the main() function returns to its original caller,
or if the exit() function is called, all open files
are closed"
"Normal termination occurs either by a call to exit()
or a return from main()."
and btw, at
MS says:
"When you call exit or execute a return statement from main,
static objects are destroyed in the reverse order of their
initialization"
> Another example where things are different is with a call to
> TerminateThread, which I believe also terminates the entire process.
well, TerminateThread is brain-damaged anyway.
> It still seems to me that POSIX and Win32 differ in how this works.
it does not seem so to me.
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk