mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
spawn: don’t error out if we fail to chdir()
This commit is contained in:
parent
064121ee95
commit
ac30da7a01
2 changed files with 7 additions and 1 deletions
6
spawn.c
6
spawn.c
|
|
@ -48,6 +48,11 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
|
|||
if (sigaction(SIGHUP, &(struct sigaction){.sa_handler = SIG_DFL}, NULL) < 0)
|
||||
goto child_err;
|
||||
|
||||
if (cwd != NULL && chdir(cwd) < 0) {
|
||||
LOG_WARN("failed to change working directory to %s: %s",
|
||||
cwd, strerror(errno));
|
||||
}
|
||||
|
||||
bool close_stderr = stderr_fd >= 0;
|
||||
bool close_stdout = stdout_fd >= 0 && stdout_fd != stderr_fd;
|
||||
bool close_stdin = stdin_fd >= 0 && stdin_fd != stdout_fd && stdin_fd != stderr_fd;
|
||||
|
|
@ -58,7 +63,6 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
|
|||
|| (close_stdout && close(stdout_fd) < 0))) ||
|
||||
(stderr_fd >= 0 && (dup2(stderr_fd, STDERR_FILENO) < 0
|
||||
|| (close_stderr && close(stderr_fd) < 0))) ||
|
||||
(cwd != NULL && chdir(cwd) < 0) ||
|
||||
execvp(argv[0], argv) < 0)
|
||||
{
|
||||
goto child_err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue