[GRASS-dev] G_list_element / G_popen

Glynn Clements glynn at gclements.plus.com
Wed Aug 9 15:50:50 EDT 2006


Radim Blazek wrote:

> There is a bug in G_list_element or G_popen, if GRASS_PAGER
> enviroment variable is not set g.list prints nothing because
> G_popen returns some a pipe (what pipe if cmd is empty?) instead of NULL.

If GRASS_PAGER isn't set, that's a bug in the startup.

Note that G_popen() doesn't use popen(), but contains its own
implementation using pipe/fork/exec. If the command fails, you will
still get the pipes; there just won't be a process on the other end of
them (technically, there will be a zombie process, which will be
reaped by G_pclose()).

If you need to handle GRASS_PAGER not being set, the most
straightforward solution would be something like:

	if (!getenv("GRASS_PAGER"))
		putenv("GRASS_PAGER=cat");

[What to use on Windows? "type" requires a filename.]

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




More information about the grass-dev mailing list