diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-20 22:34:01 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-20 22:34:01 -0400 |
commit | 8744f9406c62994e1078d7d856713e35ee7068ac (patch) | |
tree | 62614f1bdfb8611f5a0ec598a1297fba8d5305d2 | |
parent | 10dfcb09fe52a0088f94be2b8a4642f8a862dd4b (diff) | |
download | runes-8744f9406c62994e1078d7d856713e35ee7068ac.tar.gz runes-8744f9406c62994e1078d7d856713e35ee7068ac.zip |
report errors when exec fails
-rw-r--r-- | pty-unix.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -1,6 +1,7 @@ #define _XOPEN_SOURCE 600 #include <fcntl.h> #include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> #include <unistd.h> @@ -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); } } |