-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Fix failing 'Close GUI' and 'Quit GRASS' on macOS (trac #3009) #408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will comment only on wxgui.py, it looks fine, although it would be good to know what error it gives you.
Please remove unused import atexit.
# Make PID for this process on macOS, needed for enable quitting | ||
# GRASS, trac #3009. | ||
if MACOSX: | ||
kv['PID'] = str(os.getpid()) | ||
write_gisrc(kv, gisrc) | ||
exit_val = shell_process.wait() | ||
if exit_val != 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line close_gui()
and onward are not reached on macOS when exiting from GUI (no problem for close_gui()
, but problem especially for clean_all()
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close_gui()
is actually important too if there is more than one GUI running.
Hi @nilason, I can't comment on your original Perhaps you can test if this is the case with kill program in command line and whatever shell GRASS is using on your machine (I mean the one you see in the welcome message in command line under the large GRASS GIS text). As for changes in grass.py, the standard behavior is terminating shell (with typing In other words, with the current grass.py and your PR on macOS, when the GUI exists, instead of asking the terminal to quit and continuing in grass.py, the grass.py is terminated right away.
If I understand all this correctly, if you start GRASS GIS from existing shell, quitting GRASS, should not exit the parent shell. The - very common - exception is when the system is starting a terminal window just for GRASS GIS (and I don't know about it enough). However, the more transparent case is with an existing terminal and there typing exit in the shell translates to exiting GRASS GIS from user point of view, but nothing beyond that. Here is an example session:
Well, needless to say, let me know your thoughts on this and whether you observe this behavior. |
Thank you both very much for looking into this. You gave me quite a few things to think on. I need to reconsider the implementation of this PR, so please hold on. For a start I couldn't reproduce the atexit problem, now using standard Python instead of a debug version. My proposed changes to wxgui.py are therefore not necessary. |
Now I know how to reproduce the atexit issue. It wasn't the python debug build causing this, but setting grass debug variable to 1+.
Is this a mac specific behaviour? |
I can reproduce this ( |
Yes @wenzelaus, the shell isn't responding to the signal (
This is a normal
The only signal the shell_process responds to is SIGKILL, which is not acceptable. |
It turns out that manually adding a trap in bash, makes "GRASS quit" work on mac without any alterations to lib/init/grass.py. But I don't know how to make use of this info programmatically, neither in python nor perhaps in https://github.com/OSGeo/grass/blob/master/lib/init/run.c. I'd really appreciate some help.
|
From my search, esp. this Unix SE, it seems that shells often ignore SIGTERM when interactive. Do you understand this the same way? As for run.c, I'm not familiar with it and it seems to go in a different direction than what I say above. Or perhaps it is trying to behave as an interactive shell. The documentation is not clear to me. I don't understand the last part of the documentation (There is no way to tell the user's shell to re-activate interrupts in shell-ese.). run.c is so old (and stable) that it does not have any major modifications except for one for MINGW 14 years ago. Did you try removing run.c to see if it has any influence, good or bad? |
Thanks! Yes, that should be the cause of the problem. And makes the run.c aspect unrelated (I didn't quite understand what it was doing, but I could see it was poking with signals...). Now, there only remains to find a solution to this. I did come up with a solution with SIGHUP, which the shell process responds to. It did all cleanup, but left the original shell in a non-acceptable state. |
Which shell are you using? I get the same behavior with tcsh ignores SIGTERM (silently) and also
|
It is the default shell with macOS 14: bash.
|
I've updated by MacBook to OSX 15 and can test this once it is merged in and I can recompile. This is master? |
There is no acceptable fix yet, what is in the PR now is not a good fix. What you can test on macOS 15, is whether quitting (from GUI) fails on master still. I assume it will. |
OK. Master as of what date? Do I need to recompile after 4 April? |
No, any recent build would do, master, 7.8. Now, what is interesting is if macOS 15 makes any difference. |
I've already run my 4 April build on the MacBook. I had to quit the same way as before, from the terminal. I can double check though. |
@lbartoletti Is this an issue (see trac#3009) on FreeBSD as well? Or does quitting from GUI work as expected? |
Just an update. I did launch GRASS 7.9 on my MacBook with OSX 10.15. The file menu only says "Quit GUI". When I select it, it does quit the GUI and leaves you in the terminal. There is no option to quit GRASS, which did not work before. So nothing really to test. |
It's under |
I did that one too. It quit the GUI. No option to quit GRASS though. I just landed back in the terminal. |
There should be tree choices: |
I did not see the tree choices. I'll look again tonight. |
that should have been three choices or alternatives (no apple trees there:) |
;-) I thought you mean a choice tree. But if you mean a dialog should pop up with the 3 alternative buttons, it doesn't. If I click that menu choice, it just closes the GUI. This is a version I compiled on 1 April. |
I'm sure the three-button dialog is there, not under |
I rechecked this weekend. You are right. And selecting Quite GRASS just dumps you into the terminal, but does not quit GRASS. |
@cmbarton @nilason Yes, it returns on the terminal also on FreeBSD |
@lbartoletti Thanks for the info! |
This addresses the issue trac#3009.
Consists of two parts:
quitting will not quit the shell on mac, only the grass process
for some reason atexit for
gui/wxpython/wxgui.py
throws error on mac, implementation of cleanup has been alteredHas been tested on mac and win.