[GRASS-dev] BASH question about quitting GIS Manager

Glynn Clements glynn at gclements.plus.com
Thu Nov 9 02:30:52 EST 2006


Michael Barton wrote:

> Repeatedly there have been requests to make it possible to quit GRASS when
> quitting the GIS Manager (and to automatically quit the GIS Manager when
> quitting GRASS). 
> 
> I had an idea that I thought I run by everyone and see if I could get some
> suggestions about getting it to work.
> 
> 1. When the GIS Manager shell script is first run (gis.m& to run in
> background), have it set an environmental variable. For example...
> export GRASS_GUI_RUN=²TRUE²
> 
> 2. The script would idle away, waiting for any change to the environmental
> variable (this is a part I¹m not sure how to do)...
> while GRASS_GUI_RUN==²TRUE²
> ... let the GIS Manager run
> 
> 3. When the GIS Manager quits (or quits with an option to exit GRASS), it
> could set this variable to false
> set env(GRASS_GUI_RUN) ³FALSE²
> 
> 4. The script would exit its while loop and echo ³exit² to the GRASS command
> prompt, ³shutting down² GRASS (i.e., resetting the GRASS environment and
> closing the GRASS shell).
> 
> Would something like this work???
> 
> If so, we also might be able to use this for automatically quitting the GIS
> Manager. 
> -Write into the GRASS exit routine a check for the GRASS_GUI_RUN
> environmental variable
> -If it is set to TRUE, kill WISH.
> 
> What do you think?

If you want a GUI-only mode, the cleanest solution is to implement it
in Init.sh, i.e. run gis.m *instead of* the shell, rather than running
both.

If you want both, but with the shell terminated by gis.m, the cleanest
solution is for Init.sh to start gis.m instead of the shell, and for
gis.m to spawn a new xterm as a child process. gis.m will get the PID
of the xterm, which it can use to kill it when you exit.

You can't easily spawn a child shell on the existing terminal, as you
would need to do some relatively involved process management, beyond
what can readily be done in Tcl.

[E.g. putting the shell into a separate process group to wish, making
the shell the foreground process group and wish the background process
group. You might also need to undo any changes which wish made to the
terminal settings.]

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list