From: Michael D. Lowis Date: Wed, 5 Jul 2017 17:49:37 +0000 (-0400) Subject: updated die function to print the error string when requested X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=499688a5cda66f1dee5f5296bf91930da5f48ee9;p=projs%2Ftide.git updated die function to print the error string when requested --- diff --git a/lib/utils.c b/lib/utils.c index c9228dd..8608da7 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -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 06562ad..1a7d907 100644 --- 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;