From 8744f9406c62994e1078d7d856713e35ee7068ac Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 20 Apr 2014 22:34:01 -0400 Subject: report errors when exec fails --- pty-unix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pty-unix.c b/pty-unix.c index 100d4d4..643c5ba 100644 --- a/pty-unix.c +++ b/pty-unix.c @@ -1,6 +1,7 @@ #define _XOPEN_SOURCE 600 #include #include +#include #include #include @@ -25,6 +26,12 @@ void runes_pty_backend_spawn_subprocess(RunesTerm *t) } else { char *cmd; + int old_stderr_fd; + FILE *old_stderr; + + old_stderr_fd = dup(2); + fcntl(old_stderr_fd, F_SETFD, FD_CLOEXEC); + old_stderr = fdopen(old_stderr_fd, "w"); setsid(); ioctl(pty->slave, TIOCSCTTY, NULL); @@ -52,6 +59,9 @@ void runes_pty_backend_spawn_subprocess(RunesTerm *t) unsetenv("COLUMNS"); execlp(cmd, cmd, (char *)NULL); + + fprintf(old_stderr, "Couldn't run %s: %s\n", cmd, strerror(errno)); + exit(1); } } -- cgit v1.2.3-54-g00ecf