[GRASS-dev] Exit code for Tk GUI
Maris Nartiss
maris.gis at gmail.com
Mon Sep 24 04:47:32 EDT 2007
Hi,
just for record.
2007/9/24, Glynn Clements <glynn at gclements.plus.com>:
>
> An alternative is to make the initial command return wish's exit code
> (which is returned from pclose()), i.e.:
>
This was also my first idea, but, as I noted, it would break all
existing modules.
When module gets launched from console, it will create GUI via
G_parser and then use G_parser return code to exit or continue running
(assuming all required options are set, what isn't true if G_parser
was using GUI), thus getting back module fail/sucess to first running
module instance via G_parser is impossible (w/o fixing all modules).
Example from r.info:
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
Thus only way how to get back module exit code to console is by
replacing already running module with it's GUI via exec().
>
> However, that's only part of the solution, as you note in point #2
> below.
>
> > Currently such approach has some problems:
> > 1) if user hits RUN button in GUI w/o any param's, it starts another
> > module window (hint - need to look how parser determines that GUI is
> > already running);
>
> It doesn't.
It does. I have to look more closely to G_parser how to distinguish
when module is launched from GUI and then not exec() new wish
instance.
>
> To generate the dialogs, gis.m invokes the command with the --tcltk
> switch. This causes the command to write the generated code to stdout,
> rather than spawning a wish process. gis.m reads the Tcl/Tk and
> executes it locally, having previously overriden some of the
> procedures in gui.tcl (specifically, run_cmd and
> make_{buttons,output,progress}).
>
Original bugreport was referring to running module from CLI (bash) and
checking exit code via echo $?.
> > 2) still way how to get module exit code from gronsole is required.
>
> Getting the actual exit code isn't possible, AFAICT. The problem is
> that Tcl's "open |..." syntax can create a pipeline consisiting of
> multiple commands. In fact, the gronsole code always spawns two
> commands (the second is the grocat program, used to merge stdout and
> stderr).
This is biggest bummer :(
If somebody doesn't come up with some solution to this problem, then
we have to just document permanent GRASS bug - module with GUI allways
exits with error.
Maris.
More information about the grass-dev
mailing list