From dd55bc06c0116e30af3c449fe14fe04114ba649a Mon Sep 17 00:00:00 2001 From: Tomke Pfoch Date: Tue, 5 Sep 2023 17:06:28 +0000 Subject: [PATCH] Obtain footclient working directory when spawning child process --- terminal.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index f19da873..a977461d 100644 --- a/terminal.c +++ b/terminal.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -3298,8 +3299,18 @@ term_bell(struct terminal *term) bool term_spawn_new(const struct terminal *term) { + /* Get working directory of footclient instead of server + * by reading the cwd symbolic link in /proc//cwd + */ + + char cwd_link[PATH_MAX]; + char cwd[PATH_MAX]; + + snprintf(cwd_link, PATH_MAX, "/proc/%d/cwd", term->slave); + readlink(cwd_link, cwd, PATH_MAX); + return spawn( - term->reaper, term->cwd, (char *const []){term->foot_exe, NULL}, + term->reaper, cwd, (char *const []){term->foot_exe, NULL}, -1, -1, -1, NULL); }