windows exit() vs ExitProcess()

2,567 views
Skip to first unread message

Evan Martin

unread,
Jan 3, 2012, 1:58:33 PM1/3/12
to ninja...@googlegroups.com
Do any Windows experts care to comment on this patch?

https://github.com/doctorlove/ninja/commit/a4954a4f03d8e5127ee2f28691b67e5e1f5c74fd

I'm not sure I understand it.

Rachel Blum

unread,
Jan 3, 2012, 2:22:05 PM1/3/12
to ninja...@googlegroups.com
This seems odd... I'm not aware of any issues with exit() vs.
ExitProcess() on Windows. I'd love to see a source for that claim.

Rachel

Evan Martin

unread,
Jan 3, 2012, 2:42:29 PM1/3/12
to ninja...@googlegroups.com
Perhaps ExitProcess behaves more like _exit()? I know you're supposed
to use _exit in the presence of threads, but ninja doesn't use any
threads.

Philip Craig

unread,
Jan 4, 2012, 5:57:07 AM1/4/12
to ninja...@googlegroups.com
A source for the claim of different behaviour. http://stackoverflow.com/questions/915312/different-ways-of-exiting-a-process-in-c

Xoreax Incredibuild injects threads into the process being parallelised (ninja, nmake), this is why we see a behaviour difference in ninja.

Evan Martin

unread,
Jan 4, 2012, 10:44:02 AM1/4/12
to ninja...@googlegroups.com
On Wed, Jan 4, 2012 at 2:57 AM, Philip Craig <phi...@pobox.com> wrote:
> A source for the claim of different behaviour.
> http://stackoverflow.com/questions/915312/different-ways-of-exiting-a-process-in-c

Ah, so it is is really similar to _exit then, thanks!

> Xoreax Incredibuild injects threads into the process being parallelised
> (ninja, nmake), this is why we see a behaviour difference in ninja.

Wow, I didn't realize that. Do you know why?
(We used Incredibuild for Chrome but found it to be pretty unreliable,
which is too bad as it seemed pretty fancy. I think some of our
buildbot use it but few engineers do.)

Rachel Blum

unread,
Jan 4, 2012, 1:22:06 PM1/4/12
to ninja...@googlegroups.com

I might misreading this, but it seems to say pretty clearly that
ExitProcess is _not_ recommended if you're running in an environment
that uses the CRT. (Which ninja is). Having said all that...

> Xoreax Incredibuild injects threads into the process being parallelised
> (ninja, nmake), this is why we see a behaviour difference in ninja.

Sigh. Since I haven't used Incredibuild for quite a while, I wasn't
aware it did that. But sure enough, they seem to have added "Automatic
Interception" for make-based builds.
(http://www.xoreax.com/xge_xoreax_grid_engine.htm#interfaces)

If you have a case where ninja reproducibly hangs due to calling
exit/_exit, I suggest also filing a bug with the Incredibuild guys -
the only way that can happen would be for them to do infinite waits in
atexit() functions they injected.

Rachel

Scott Graham

unread,
Jan 4, 2012, 1:42:55 PM1/4/12
to ninja...@googlegroups.com
On Wed, Jan 4, 2012 at 7:44 AM, Evan Martin <mar...@danga.com> wrote:
On Wed, Jan 4, 2012 at 2:57 AM, Philip Craig <phi...@pobox.com> wrote:
> A source for the claim of different behaviour.
> http://stackoverflow.com/questions/915312/different-ways-of-exiting-a-process-in-c

Ah, so it is is really similar to _exit then, thanks!


I'm still a little skeptical on ExitProcess too (seems like a bug in IB if they really broke exit()), but probably could just use _exit everywhere to avoid the #if (http://msdn.microsoft.com/en-us/library/6wdz5232.aspx)
Reply all
Reply to author
Forward
0 new messages