aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-09-26 17:16:40 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-10-02 18:11:16 +0000
commit332cb90134bf7ba4f5248147aeee9f8f6a99a579 (patch)
treec360749c8f2e5145fed9f6e42912ee7757802407
parentmain/client: use $PWD for cwd, when $PWD is valid (diff)
spawn: set $PWD, in addition to calling chdir(cwd)
-rw-r--r--spawn.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/spawn.c b/spawn.c
index 7c6641da..90b892f3 100644
--- a/spawn.c
+++ b/spawn.c
@@ -54,9 +54,12 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
goto child_err;
}
- if (cwd != NULL && chdir(cwd) < 0) {
- LOG_WARN("failed to change working directory to %s: %s",
- cwd, strerror(errno));
+ if (cwd != NULL) {
+ setenv("PWD", cwd, 1);
+ if (chdir(cwd) < 0) {
+ LOG_WARN("failed to change working directory to %s: %s",
+ cwd, strerror(errno));
+ }
}
if (xdg_activation_token != NULL) {