aboutsummaryrefslogtreecommitdiff
path: root/slave.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-01 22:49:54 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-01 22:49:54 +0000
commit25311fc4eb278d41cb29e1d0dd8dccff07617713 (patch)
tree0f72cc86b04b5e3ac0e9429f386d227151b79406 /slave.c
parentMerge branch 'term-init-cleanup' (diff)
parentclient: register signal handler for SIGTERM too (diff)
Merge branch 'multi-window'
Diffstat (limited to 'slave.c')
-rw-r--r--slave.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/slave.c b/slave.c
index df784a7f..1f70a0d8 100644
--- a/slave.c
+++ b/slave.c
@@ -1,5 +1,6 @@
#define _XOPEN_SOURCE 500
#include "slave.h"
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -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;
@@ -107,7 +110,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");
@@ -119,11 +122,11 @@ 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);
+ LOG_DBG("%s: successfully started", conf_shell);
break;
}
}