[GRASS-SVN] r43806 -
grass/branches/releasebranch_6_4/display/d.mon/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 6 05:56:28 EDT 2010
Author: hamish
Date: 2010-10-06 09:56:28 +0000 (Wed, 06 Oct 2010)
New Revision: 43806
Modified:
grass/branches/releasebranch_6_4/display/d.mon/cmd/main.c
Log:
use G_spawn() instead of G_system() (merge r43530 from devbr6)
Modified: grass/branches/releasebranch_6_4/display/d.mon/cmd/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.mon/cmd/main.c 2010-10-06 08:41:45 UTC (rev 43805)
+++ grass/branches/releasebranch_6_4/display/d.mon/cmd/main.c 2010-10-06 09:56:28 UTC (rev 43806)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/spawn.h>
#include <grass/glocale.h>
/* Changed for truecolor 24bit support by
@@ -30,7 +31,7 @@
* example; nlev=8 means 8bit for each R, G, B equal to 24bit truecolor
*/
-int run(char *, char *);
+int run(char *, char *, char *);
int main(int argc, char *argv[])
{
@@ -98,7 +99,7 @@
exit(EXIT_FAILURE);
if (unlock->answer)
- run("release -f", unlock->answer);
+ run("release", "-f", unlock->answer);
if (!select->answer && !no_auto_select->answer)
select->answer = start->answer;
@@ -108,15 +109,15 @@
error = 0;
if (status->answer)
- error += run("status", "");
+ error += run("status", "", "");
else if (list->answer)
- error += run("list", "");
+ error += run("list", "", "");
if (release->answer)
- error += run("release", "");
+ error += run("release", "", "");
if (stop->answer)
- error += run("stop", stop->answer);
+ error += run("stop", "", stop->answer);
if (start->answer) {
- error += run("start", start->answer);
+ error += run("start", "", start->answer);
if (error) { /* needed procedure failed */
if (mon_name != NULL) {
/* restore the previous environ. */
@@ -127,11 +128,12 @@
}
}
if (select->answer) {
- oops = run("select", select->answer); /* couldn't select */
- if (oops && start->answer && strcmp(start->answer, select->answer) == 0) { /* try once more */
+ oops = run("select", "", select->answer); /* couldn't select */
+ if (oops && start->answer && strcmp(start->answer, select->answer) == 0) {
+ /* try once more */
G_message(_("Problem selecting %s. Will try once more"),
select->answer);
- oops = run("select", select->answer); /* couldn't select */
+ oops = run("select", "", select->answer); /* couldn't select */
}
if (oops) { /* needed procedure failed */
if (mon_name != NULL) {
@@ -144,17 +146,26 @@
error += oops;
}
if (print->answer)
- error += run("which", "");
+ error += run("which", "", "");
+
exit(error ? EXIT_FAILURE : EXIT_SUCCESS);
}
-int run(char *pgm, char *name)
+int run(char *pgm, char *flags, char *name)
{
- char command[1024];
+ char path[GPATH_MAX];
+ int stat;
- sprintf(command, "\"%s\"/etc/mon.%s %s", G_gisbase(), pgm, name);
+ sprintf(path, "%s/etc/mon.%s", G_gisbase(), pgm);
- G_debug(1, "run: [%s]", command);
+ if (*flags) {
+ if ((stat = G_spawn(path, pgm, flags, name, NULL)))
+ G_sleep(3);
+ }
+ else {
+ if ((stat = G_spawn(path, pgm, name, NULL)))
+ G_sleep(3);
+ }
- return G_system(command);
+ return stat;
}
More information about the grass-commit
mailing list