From 98ccd01c1b9f273c26466afcfba6f50c57e74cbb Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 30 Oct 2019 20:20:56 +0100 Subject: slave: fix debug logging (no 'term' variable) --- slave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'slave.c') diff --git a/slave.c b/slave.c index df784a7f..a4ff67a1 100644 --- a/slave.c +++ b/slave.c @@ -107,7 +107,7 @@ slave_spawn(int ptmx, int argc, char *const *argv, default: { close(fork_pipe[1]); /* Close write end */ - LOG_DBG("slave has PID %d", term->slave); + LOG_DBG("slave has PID %d", pid); int _errno; static_assert(sizeof(errno) == sizeof(_errno), "errno size mismatch"); @@ -123,7 +123,7 @@ slave_spawn(int ptmx, int argc, char *const *argv, "%s: failed to execute", argc == 0 ? conf_shell : argv[0]); return -1; } else - LOG_DBG("%s: successfully started", conf->shell); + LOG_DBG("%s: successfully started", conf_shell); break; } } -- cgit v1.3 From 54039c1fb44b691abe94fc412696bdc5e14d0a93 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 30 Oct 2019 20:21:19 +0100 Subject: slave: log child's errno, not parents --- slave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'slave.c') diff --git a/slave.c b/slave.c index a4ff67a1..0e762bf0 100644 --- a/slave.c +++ b/slave.c @@ -119,8 +119,8 @@ slave_spawn(int ptmx, int argc, char *const *argv, LOG_ERRNO("failed to read from pipe"); return -1; } else if (ret == sizeof(_errno)) { - LOG_ERRNO( - "%s: failed to execute", argc == 0 ? conf_shell : argv[0]); + LOG_ERRNO_P( + "%s: failed to execute", _errno, argc == 0 ? conf_shell : argv[0]); return -1; } else LOG_DBG("%s: successfully started", conf_shell); -- cgit v1.3 From 69d62d3cd2918bee089fc879e381820349497483 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 1 Nov 2019 21:01:15 +0100 Subject: slave: set TERM environment variable in slave process --- main.c | 1 - slave.c | 5 ++++- slave.h | 2 +- terminal.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) (limited to 'slave.c') diff --git a/main.c b/main.c index f13a45d8..c1abe5bc 100644 --- a/main.c +++ b/main.c @@ -161,7 +161,6 @@ main(int argc, char *const *argv) argv += optind; setlocale(LC_ALL, ""); - setenv("TERM", conf.term, 1); struct fdm *fdm = NULL; struct wayland *wayl = NULL; diff --git a/slave.c b/slave.c index 0e762bf0..1f70a0d8 100644 --- a/slave.c +++ b/slave.c @@ -1,5 +1,6 @@ #define _XOPEN_SOURCE 500 #include "slave.h" + #include #include #include @@ -68,7 +69,7 @@ err: pid_t slave_spawn(int ptmx, int argc, char *const *argv, - const char *conf_shell) + const char *term_env, const char *conf_shell) { int fork_pipe[2]; if (pipe2(fork_pipe, O_CLOEXEC) < 0) { @@ -88,6 +89,8 @@ slave_spawn(int ptmx, int argc, char *const *argv, /* Child */ close(fork_pipe[0]); /* Close read end */ + setenv("TERM", term_env, 1); + char **_shell_argv = NULL; char *const *shell_argv = argv; diff --git a/slave.h b/slave.h index cfb18af2..f1a9848a 100644 --- a/slave.h +++ b/slave.h @@ -4,4 +4,4 @@ #include pid_t slave_spawn( - int ptmx, int argc, char *const *argv, const char *conf_shell); + int ptmx, int argc, char *const *argv, const char *term_env, const char *conf_shell); diff --git a/terminal.c b/terminal.c index cbe67b58..d6aaf4ff 100644 --- a/terminal.c +++ b/terminal.c @@ -428,7 +428,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height); /* Start the slave/client */ - if ((term->slave = slave_spawn(term->ptmx, argc, argv, conf->shell)) == -1) + if ((term->slave = slave_spawn(term->ptmx, argc, argv, conf->term, conf->shell)) == -1) goto err; /* Initiailze the Wayland window backend */ -- cgit v1.3