aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-20 22:34:01 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-20 22:34:01 -0400
commit8744f9406c62994e1078d7d856713e35ee7068ac (patch)
tree62614f1bdfb8611f5a0ec598a1297fba8d5305d2
parent10dfcb09fe52a0088f94be2b8a4642f8a862dd4b (diff)
downloadrunes-8744f9406c62994e1078d7d856713e35ee7068ac.tar.gz
runes-8744f9406c62994e1078d7d856713e35ee7068ac.zip
report errors when exec fails
-rw-r--r--pty-unix.c10
1 files changed, 10 insertions, 0 deletions
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 <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);
}
}