mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
eval: allow setting cwd in {jobstart,termopen}()
Processes in vim are always started in the current directory, which causes issues when the process is a daemon and the current directory is a mountpoint. Fix this by adding an option to set the cwd of the new process with jobstart(). In addition, fix termopen() so that it actually uses the cwd option from the dict (it couldn't previously set the cwd value due to dead code). Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "nvim/event/process.h"
|
||||
#include "nvim/os/pty_process_unix.h"
|
||||
#include "nvim/log.h"
|
||||
#include "nvim/os/os.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "os/pty_process_unix.c.generated.h"
|
||||
@@ -131,6 +132,12 @@ static void init_child(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL
|
||||
signal(SIGTERM, SIG_DFL);
|
||||
signal(SIGALRM, SIG_DFL);
|
||||
|
||||
Process *proc = (Process *)ptyproc;
|
||||
if (proc->cwd && os_chdir(proc->cwd) != 0) {
|
||||
fprintf(stderr, "chdir failed: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
setenv("TERM", ptyproc->term_name ? ptyproc->term_name : "ansi", 1);
|
||||
execvp(ptyproc->process.argv[0], ptyproc->process.argv);
|
||||
fprintf(stderr, "execvp failed: %s\n", strerror(errno));
|
||||
|
Reference in New Issue
Block a user