From 332cb90134bf7ba4f5248147aeee9f8f6a99a579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 26 Sep 2022 19:16:40 +0200 Subject: [PATCH] spawn: set $PWD, in addition to calling chdir(cwd) --- spawn.c | 9 ++++++--- 1 file 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) {