From 5250593129b14feae02fdf449d5bf68b8c12ab70 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 27 Nov 2018 21:49:57 +1100 Subject: [PATCH] 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. --- src/shell_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 3683c85f0..be8a8b2f4 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -107,7 +107,7 @@ pid_t spawn_shell(const char* shell, StringView cmdline, execparams.push_back(param.c_str()); execparams.push_back(nullptr); - if (pid_t pid = fork()) + if (pid_t pid = vfork()) return pid; setup_child();