From 499688a5cda66f1dee5f5296bf91930da5f48ee9 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 5 Jul 2017 13:49:37 -0400 Subject: [PATCH] updated die function to print the error string when requested --- lib/utils.c | 6 ++++-- pty.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) 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; -- 2.49.0