Whamcloud - gitweb
libss: ss_execute_line: reflect any error codes from system() to the caller
authorTheodore Ts'o <tytso@mit.edu>
Wed, 22 Apr 2009 18:46:48 +0000 (14:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 22 Apr 2009 18:46:48 +0000 (14:46 -0400)
This is primarily to silence a gcc warning, but it's better to reflect
the error from system() up to the caller.  In this case we don't
actually use it for anything, but that's OK.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ss/execute_cmd.c

index e9c65f6..bc2a204 100644 (file)
 #ifdef HAS_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#else
+extern int errno;
+#endif
 #include "ss_internal.h"
 #include <stdio.h>
 
@@ -213,8 +218,7 @@ int ss_execute_line (sci_idx, line_ptr)
             return SS_ET_ESCAPE_DISABLED;
         else {
             line_ptr++;
-            system(line_ptr);
-           return 0;
+            return (system(line_ptr) < 0) ? errno : 0;
         }
     }