]> git.mdlowis.com Git - projs/tide.git/commitdiff
updated die function to print the error string when requested
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 5 Jul 2017 17:49:37 +0000 (13:49 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 5 Jul 2017 17:49:37 +0000 (13:49 -0400)
lib/utils.c
pty.c

index c9228ddc639556331b323eba0bb7cbe78f3bf4f1..8608da73f44b74340db93eb8760efa842ca9be15 100644 (file)
@@ -66,10 +66,12 @@ uint64_t getmillis(void) {
 void die(const char* msgfmt, ...) {
     va_list args;
     va_start(args, msgfmt);
-    fprintf(stderr, "Error: ");
+    fprintf(stderr, "error: ");
     vfprintf(stderr, msgfmt, args);
-    fprintf(stderr, "\n");
     va_end(args);
+    if (*msgfmt && msgfmt[strlen(msgfmt)-1] == ':')
+        fprintf(stderr, " %s", strerror(errno));
+    fprintf(stderr, "\n");
     exit(EXIT_FAILURE);
 }
 
diff --git a/pty.c b/pty.c
index 06562ade724cc7e9c163c437df07b2c568504a1b..1a7d9079d30b93e03a32e527159e4e1ee908fdaa 100644 (file)
--- a/pty.c
+++ b/pty.c
@@ -25,7 +25,8 @@ int pty_spawn(char** argv) {
             break;
 
         case 0: // Child Process
-            execvp(argv[0], argv);
+            if (execvp(argv[0], argv) < 0)
+                die("execvp('%s', ...) :", argv[0]);
             exit(EXIT_FAILURE);
             break;