|
From: Tatsuro M. <tma...@ya...> - 2017-02-28 05:57:55
|
----- Original Message ----- > From: sfeam > To: gnuplot-beta Tatsuro MATSUOKA > Cc: > Date: 2017/2/28, Tue 13:51 > Subject: Re: Is gp_exit() used at exit in current gnuplot? > > On Tuesday, 28 February 2017 10:38:04 AM Tatsuro MATSUOKA wrote: >> This is related to bug #1913. >> >> In stdfn.c >> >> there stated >> >> >> /* Calls the cleanup functions registered using gp_atexit(). >> * Normally gnuplot should be exited using gp_exit(). In some cases, this > is not >> * possible (notably when returning from main(), where some compilers get >> * confused because they expect a return statement at the very end. In that >> * case, gp_exit_cleanup() should be called before the return statement. >> */ >> >> >> ***************************** >> Normally gnuplot should be exited using gp_exit(). >> *************************** > > I think the intended meaning is > "If you were going to terminate the program by calling exit(), don't do > that. > Instead call gp_exit()." > > However the normal exit from main() in a C language program is by > "return", not "exit()". > So gnuplot's main() routine does not call either exit() or gp_exit(). > Instead it calls > gp_exit_cleanup() followed by "return". > Thus it does exactly what the comment describes. > >> Excuse me for my writing without reading the code in detail. >> gp_exit() seems to be used in many place in the code. >> Therefore gp_exit() is surely used in current gnuplot. > > Yes. For example If you say > gnuplot> exit gnuplot > then it calls gp_exit(). > >> However, "gnuplot> exit" does not use gp_exit() as written in > the >> previous post. >> >> I feel that the message >> >> Gnuplot not exited using gp_exit(). Exit handlers may not work correctly! >> >> in debug_exit_handler in stdfn.c is better to be modified. > > I think you are correct that the message is not accurate. > It would be better to say > "Gnuplot not exiting normally. Exit handlers may not work correctly!" > gp_exit() is one way of exiting normally, but exiting by return from main() > is also a way of exiting normally. > > In your case (Bug 1913) I guess neither of these normal ways to exit is > happening. > Instead gnuplot is killed by the operating system because you hit the "X > button". > > Ethan > > > Thank you for your comprehensive explanation. I hope that message in debug_exit_handler will be modified as you indicaded "Gnuplot not exiting normally. Exit handlers may not work correctly!" Tatsuro |