ShellManager: Use vfork instead of fork

When large buffers have been opened, copying Kakoune's memory
page descriptors can get pretty slow, making fork more expensive
than necessary.

vfork avoids that problem. While not strictly conforming, it seems
the few calls we do before execve (open, close, dup2 and
set_signal_handler) would not cause any problems on platforms we
care about.
This commit is contained in:
Maxime Coste 2018-11-27 21:49:57 +11:00
parent c6d6060502
commit 5250593129

View File

@ -107,7 +107,7 @@ pid_t spawn_shell(const char* shell, StringView cmdline,
execparams.push_back(param.c_str()); execparams.push_back(param.c_str());
execparams.push_back(nullptr); execparams.push_back(nullptr);
if (pid_t pid = fork()) if (pid_t pid = vfork())
return pid; return pid;
setup_child(); setup_child();