[rrd-developers] rrdtool 1.0.49 return error code (fwd)

Haroon Rafique haroon.rafique at utoronto.ca
Thu Oct 21 19:44:28 MEST 2004


Second message that I didn't get any replies on the rrd-users list, so 
trying the developers list.

--
Haroon Rafique
<haroon.rafique at utoronto.ca>


---------- Forwarded message ----------
Date: Fri, 1 Oct 2004 11:15:48 -0400 (EDT)
From: Haroon Rafique <haroon.rafique at utoronto.ca>
To: rrd-users at list.ee.ethz.ch
Subject: [rrd-users] rrdtool 1.0.49 return error code

Hi listers,

I have a question regarding return codes from rrdtool 1.0.49.

If I execute:

  	rrdtool update /blah/nonexistent/file/path

Shouldn't the value of $? afterwards be non-zero.

Here's what I get when executing:

prompt$	rrdtool update /blah/nonexistent/file/path; echo $?
ERROR: Not enough arguments
0

Basically, I'm implying that the error handling from the rrd_*.c files
should sort of bubble up so that the main program can return a non-zero
error code. Would be a useful feature when running the updates via shells
to look for errors.

The following diff seems to work for me.

--- src/rrd_tool.c.orig 2004-08-08 06:58:14.000000000 -0400
+++ src/rrd_tool.c      2004-10-01 11:08:51.389447262 -0400
@@ -263,8 +263,11 @@
                  PrintUsage(argv[1]);
                  exit(0);
          }
-    else
-       HandleInputLine(argc, argv, stderr);
+    else {
+        if(HandleInputLine(argc, argv, stderr)) {
+            return 1;
+        }
+    }
       return 0;
   }

@@ -426,6 +429,7 @@
       if (rrd_test_error()) {
          fprintf(out, "ERROR: %s\n",rrd_get_error());
          rrd_clear_error();
+        return 1;
       }
       return(0);
   }

The tabbing is a mish-mash in the original file, so for this tiny patch,
you might wanna just apply it by hand.

After applying the above diff, and executing the command, gives me:

rrdtool update /path/to/nonexistent/file;  echo $?
ERROR: Not enough arguments
1

Hopefully this will get adopted into the main branch if people find it
useful.

Regards,
--
Haroon Rafique
<haroon.rafique at utoronto.ca>

--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-developers mailing list