[Ikvm-developers] System.exit vs. System.Environment.Exit
Brought to you by:
jfrijters
From: Chas E. <cem...@sn...> - 2012-06-13 18:52:27
|
In the process of starting to use mono, I ran into some behaviour where the executable generated by gmcs — which depended upon ikvm and a DLL generated by ikvmc — would not exit once control left the Main(string[]) method, requiring manual termination (with e.g. ^C) in order to get back to the shell. I added a System.Environment.Exit call, which never returned, but never terminated the process either. Baffled, I flailed around for a while (i.e. posting on the issue here: http://stackoverflow.com/questions/11006506/console-mono-executables-do-not-exit-when-completed) before replacing the System.Environment.Exit call with a java.lang.System.exit call. 'lo and behold, the program exited as expected. I'm happy that the program is now working 100% as expected under mono, but I'd like to understand why System.exit() worked, whereas System.Environment.Exit did not. I have a hunch that there's some kind of finalizer or non-daemon thread at the root of it, though I would expect the latter call to provoke the same IKVM cleanup/termination that apparently succeeds via the former. FWIW, the program in question is single-threaded; neither it nor the ikvmc-generated DLL start any threads explicitly. While the app is headless, and doesn't create any forms, it does use certain AWT classes (like java.awt.Point and java.awt.geom.GeneralPath); however, none of this usage provokes the start of the AWT event queue, at least when run on the JVM. Cheers, - Chas |