[GRASS-dev] [GRASS GIS] #508: hardcoded /dev/null

#508: hardcoded /dev/null
--------------------------------+-------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Keywords: wingrass /dev/null | Platform: MSWindows XP
      Cpu: x86-32 |
--------------------------------+-------------------------------------------
Hi,

{{{
imagery/i.cluster/main.c
raster/r.out.mpeg/main.c
raster/r.topmodel/misc.c
lib/gis/opencell.c G__open_cell_old()
}}}
all hardcode to /dev/null which doesn't exist on Windows.

perhaps
{{{
#ifdef __MINGW32__
#define NULLDEV "NUL:"
#else
#define NULLDEV "/dev/null"
#endif
}}}
or somesuch? (no idea)

d.ask and XDRIVER do too, but they don't work on MS Windows.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/508&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass /dev/null
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [ticket:508 hamish]:
> perhaps
{{{
#ifdef __MINGW32__
#define NULLDEV "NUL:"
#else
#define NULLDEV "/dev/null"
#endif
}}}
> or somesuch? (no idea)

See G_DEV_NULL in gis.h

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/508#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass /dev/null
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

i.cluster, r.topmodel, and lib/gis/opencell.c updated in r36143 - r36148.

For grass 6 I am not really sure what to do with r.mapcalc from
r.topmodel/misc.c. I can do
{{{
   G_putenv("GRASS_VERBOSE", "0");
}}}

but then how to undo that as soon as r.mapcalc is done? ie so you don't
override user's verbosity setting for everything that happens afterwards
in the module. on unix you could put "GRASS_VERBOSE=0 r.mapcalc ..." on
the same line, dunno if that works for windows.

n.b. old >/dev/null didn't catch G_percent() as it is to stderr not
stdout.

Also I am not sure how to fix r.out.mpeg (sends 2> /dev/null), so that one
remains to be fixed.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/508#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
--------------------------------+-------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass /dev/null | Platform: MSWindows XP
      Cpu: x86-32 |
--------------------------------+-------------------------------------------

Comment(by neteler):

The remaining /dev/null are

{{{
find . -name '*.c' | xargs grep '/dev/null'
./raster/r.out.mpeg/main.c: if (256 == G_system("ppmtompeg 2>
/dev/null"))
./raster/r.out.mpeg/main.c: else if (256 == G_system("mpeg_encode 2>
/dev/null"))
./raster/r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null >
/dev/null", encoder, mpfilename);
./raster/r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null >
/dev/null", encoder, mpfilename);
./raster/r.out.mpeg/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2>
/dev/null",
./display/drivers/XDRIVER/Serve_Xevent.c: open("/dev/null", O_RDONLY);
./display/drivers/XDRIVER/Serve_Xevent.c: open("/dev/null", O_WRONLY);
./display/drivers/XDRIVER/Serve_Xevent.c: open("/dev/null", O_WRONLY);
./display/d.ask/main.c: fd = popen("d.menu tcolor=red > /dev/null", "w");
./visualization/xganim/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2>
/dev/null", path, wildarg,
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/508#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
--------------------------------+-------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass /dev/null | Platform: MSWindows XP
      Cpu: x86-32 |
--------------------------------+-------------------------------------------

Comment(by hamish):

as in comment:2 I'm not sure how to fix r.out.mpeg.
XDRIVER and d.ask aren't an issue for WinGrass.
I'm not sure if xganim could be made to work on WinGrass or not, but it's
better replaced by the wxGUI animator version. (?)

So I'd be happy to close the bug as long as r.out.mpeg could get fixed.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/508#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
--------------------------------+-------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass /dev/null | Platform: MSWindows XP
      Cpu: x86-32 |
--------------------------------+-------------------------------------------

Comment(by glynn):

Replying to [comment:4 hamish]:
> as in comment:2 I'm not sure how to fix r.out.mpeg.

{{{
G_system("ppmtompeg 2>" G_DEV_NULL);
}}}

A more significant issue is gee_wildfiles(), which does:
{{{
     sprintf(cmd, "cd %s; \\ls %s >> %s 2> /dev/null",
             path, wildarg, tfile);
}}}

If you want a complete replacement, the 7.0 version of xganim uses
G_spawn_ex() and g.mlist.

> I'm not sure if xganim could be made to work on WinGrass or not, but
it's better replaced by the wxGUI animator version. (?)

The 6.x xganim requires Motif and an X server, which is probably more
trouble than it's worth. Also, on Windows and MacOSX you would need to
either use Lesstif (which is still "beta" quality and barely maintained)
or buy a commercial version of Motif; the OpenMotif licence is limited to
open-source platforms.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/508#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
--------------------------------+-------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass /dev/null | Platform: MSWindows XP
      Cpu: x86-32 |
--------------------------------+-------------------------------------------
Changes (by hellik):

  * milestone: 6.4.0 => 6.4.2

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/508#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
---------------------------------------------+------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.4
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass, /dev/null, r.out.mpeg | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------------------+------------------------------
Changes (by hamish):

  * keywords: wingrass /dev/null => wingrass, /dev/null, r.out.mpeg
  * milestone: 6.4.2 => 6.4.4

Comment:

r.out.mpeg still needs fixing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/508#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#508: hardcoded /dev/null
---------------------------------------------+------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.4
Component: Default | Version: 6.4.0 RCs
Keywords: wingrass, /dev/null, r.out.mpeg | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------------------+------------------------------

Comment(by wenzeslaus):

Replying to [comment:5 glynn]:
> Replying to [comment:4 hamish]:
> > I'm not sure if xganim could be made to work on WinGrass or not, but
it's better replaced by the wxGUI animator version. (?)
>
> The 6.x xganim requires Motif and an X server, which is probably more
trouble than it's worth. Also, on Windows and MacOSX you would need to
either use Lesstif (which is still "beta" quality and barely maintained)
or buy a commercial version of Motif; the OpenMotif licence is limited to
open-source platforms.

Just for the record, `xganim` was removed from GRASS 7 in favor of
`g.gui.animation`.

For trunk, both `egrep -Irn "NULLDEV"` and `egrep -Irn "/dev/null"` return
nothing for `raster/r.out.mpeg`.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/508#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>