aboutsummaryrefslogtreecommitdiff
path: root/slave.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-01-03 13:07:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-01-03 13:07:15 +0000
commit66f25bb4346eab9b7914213343d22ee67c57724f (patch)
tree72a7966ce7a5de0dff9d40c398fc43e7ef6ec3e9 /slave.c
parentAdd poimandres theme (diff)
slave: chdir to / after spawning the client application
With this patch, the terminal process now changes PWD to / after spawning the client application. This ensures the terminal process itself does not "lock" a directory. For example, we may keep a mount point from being unmounted. Closes #1528
Diffstat (limited to 'slave.c')
-rw-r--r--slave.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/slave.c b/slave.c
index ecfce7e6..1184d0c2 100644
--- a/slave.c
+++ b/slave.c
@@ -401,6 +401,14 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
break;
default: {
+
+ /*
+ * Don't stay in CWD, since it may be an ephemeral path. For
+ * example, it may be a mount point of, say, a thumb drive. Us
+ * keeping it open will prevent the user from unmounting it.
+ */
+ chdir("/");
+
close(fork_pipe[1]); /* Close write end */
LOG_DBG("slave has PID %d", pid);