src/lib/common.c 1.135

1.135 2009/11/02 21:27:48 hiram
Allow maybeSystem() to only warn on system errors. trf always exits with an error
Index: src/lib/common.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/common.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -b -B -U 4 -r1.134 -r1.135
--- src/lib/common.c	20 Oct 2009 19:49:24 -0000	1.134
+++ src/lib/common.c	2 Nov 2009 21:27:48 -0000	1.135
@@ -2072,10 +2072,21 @@
 slReverse(&newList);
 return newList;
 }
 
+void maybeSystem(char *cmd)
+/* Execute cmd using "sh -c" or die.  (See man 3 system.) warn on errors */
+{
+if (cmd == NULL) // don't allow (system() supports testing for shell this way)
+    errAbort("mustSystem: called with NULL command.");
+int status = system(cmd);
+if (status != 0)
+    warn("maybeSystem: system(%s) failed (exit status %d): %s",
+	     cmd, WEXITSTATUS(status), strerror(errno));
+}
+
 void mustSystem(char *cmd)
-/* Execute cmd using "sh -c" or die.  (See man 3 system.) */
+/* Execute cmd using "sh -c" or die.  (See man 3 system.) fail on errors */
 {
 if (cmd == NULL) // don't allow (system() supports testing for shell this way)
     errAbort("mustSystem: called with NULL command.");
 int status = system(cmd);