We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Strange behaviour of exit()!! (Read 811 times)
Strange behaviour of exit()!!
Oct 8th, 2007, 2:37am
 
Hi,
I'm a C++ Programmer with a slight knowledge of Java. I'm using Processing for past 2 months but used this exit() function for the first time - and am surprised to see its strange behaviour - it exits from the program only after the draw function executes completely!! That means, if we are using this in a while() block, and if we write exit() in it, it will have no effect at all !!

Do we have any other function which is same as the normal exit() function which exits just when we write it?
Re: Strange behaviour of exit()!!
Reply #1 - Oct 18th, 2007, 2:42pm
 
this behavior is clearly stated in the reference:
http://processing.org/reference/exit_.html

unlike a c++ program, a processing sketch cannot simply terminate in the middle of a draw(), it could easily crash your system if you're using opengl or that sort of thing.

to force termination, you can use java's System.exit(0), but this would be bad style anyway (and leave you subject to potential crashing).
Re: Strange behaviour of exit()!!
Reply #2 - Oct 18th, 2007, 2:48pm
 
Thanks. For some bad reason, I need to use this System.exit(0) only Smiley
Page Index Toggle Pages: 1