[GRASS-dev] Re: not quite there on fonts
glynn at gclements.plus.com
Fri May 11 16:23:55 EDT 2007
Paul Kelly wrote:
> On Fri, 11 May 2007, Michael Barton wrote:
> > GRASS_RENDER_IMMEDIATE is set prior to rendering and unset immediately
> > after. The reason is that it doesn't affect any command-line use of GRASS.
GRASS_RENDER_IMMEDIATE is an environment variable.
Every process has its own set of environment variables. Setting
$env(GRASS_RENDER_IMMEDIATE) in gis.m will only affect processes which
are spawned by gis.m; it can't affect those run from the shell.
Paul Kelly wrote:
> So you're saying if you start a Tcl application (e.g. gis.m) from a Unix
> shell, and then set an environment variable within the Tcl application,
> that the shell kind of inherits it backwards and commands run from there
> will be affected by the changed environment?
I suppose that's what he was thinking, but that's incorrect.
The environment is part of a process' address space. Every process has
its own environment. The environment is duplicated along with the rest
of the address space by fork(), while execve() takes the environment
as an argument. The other exec* functions are all wrappers around
execve(); those without the "e" suffix simply pass the existing
IOW, a child process will normally inherit its environment from its
parent; thereafter, a process can modify its own environment, but not
the environment of another process.
> I didn't think of that - I
> suppose it would be better if Tcl allowed you to specify environment
> variables that applied only to it and commands spawned from it.
> But I suppose anyway you can work around it in this case by setting
> GRASS_RENDER_IMMEDIATE before running d.font -l and unsetting it
There's no need. gis.m could leave GRASS_RENDER_IMMEDIATE set to TRUE
at all times, and only unset it when spawning a child process which is
going to use an X monitor.
With Python, the situation is better, as the Popen constructor allows
you to specify an explicit environment for each process. Tcl lacks
this, so you have to modify your own environment and let the child
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev