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
This commit is contained in:
Daniel Eklöf 2024-01-03 14:07:15 +01:00
parent 14472cdbd9
commit 66f25bb434
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 13 additions and 0 deletions

View file

@ -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);