[GRASS-dev] Re: [Qgis-developer] Windows native GRASS build

Glynn Clements glynn at gclements.plus.com
Fri Jan 5 07:26:26 EST 2007


Brad Douglas wrote:

> > >>> /src/grass6/raster/r.li/r.li.daemon
> > >>> /src/grass6/raster/r.li/r.li.edgedensity
> > >>> /src/grass6/raster/r.li/r.li.patchdensity
> > >>> /src/grass6/raster/r.li/r.li.patchnumber
> > >>> /src/grass6/raster/r.li/r.li.shape
> > >>> /src/grass6/raster/r.li/r.li.simpson
> > >>> /src/grass6/raster/r.li/r.li.shannon
> > >>> /src/grass6/raster/r.li/r.li.meanPatchSize
> > >>> /src/grass6/raster/r.li/r.li.meanPixelAttribute
> > >>> /src/grass6/raster/r.li/r.li.patchAreaDistributionCV
> > >>> /src/grass6/raster/r.li/r.li.patchAreaDistributionSD
> > >>> /src/grass6/raster/r.li/r.li.patchAreaDistributionRANGE
> > >>> /src/grass6/raster/r.li/r.li.contrastWeightedEdgeDensity
> > >>> /src/grass6/raster/r.li/r.li.richness
> > >>> /src/grass6/raster/r.li/r.li.dominance
> > >>
> > >> Not crucial.
> > >
> > > Agreed, but we would like to have it. Tim, could you please forward the
> > > errors to Serena Pallecchi, Davide Spano and Claudio Porta?
> > 
> > Please see attached. Main problems as far as I can see:
> > - Use of FIFOs? AIUI Windows doesn't have FIFOs so that won't work.
> > - Also I don't think fork() is available on Windows either - Glynn may be 
> > able to advise.
> 
> Linux: fork() exec()
> Win32: CreateProcess()
> 
> Linux: exit()
> Win32: ExitProcess()
> 
> Linux: get/putenv()
> Win32: Get/SetEnvironmentVariable()
> 
> Linux: waitpid()
> Win32: GetExitCodeProcess()
> 
> Linux; getpid()
> Win32: GetCurrentProcessId()
> 
> It would be nice to have wrappers for these functions.  Thoughts, Glynn?

There are limits to "wrapping" process management. It isn't as if Unix
and Windows are the same except for the names given to the functions;
the semantics are quite different. Particularly the Unix model of
separate fork() and exec(), with the ability to substantially alter
the state of the child between the two, versus a single
CreateProcess() call with a fixed set of parameters.

Having said that, you could wrap the simpler cases. You would need to
stick to what's available on Windows; some of the more complex things
which can be done on Unix either aren't possible on Windows (e.g. 
setting descriptors other than stdin/stdout/stderr) or don't have any
equivalent there (e.g. signal handling).

I already started writing potential replacements for typical usage of
system(); see lib/gis/spawn.c. G_spawn() is a direct replacement for
the simplest uses of system(), except that it accepts individual
arguments rather than a single string and doesn't use "sh -c ...". 
G_spawn_ex() is intended to handle more advanced usage, e.g. 
redirection, signal handling, environment variable substitution and
binding.

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




More information about the grass-dev mailing list