From 66f25bb4346eab9b7914213343d22ee67c57724f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 3 Jan 2024 14:07:15 +0100 Subject: 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 --- slave.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'slave.c') 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); -- cgit v1.3