From 74fc52b3de6927632b5a8484f68f68bd34f383d5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 22 Jan 2021 17:15:59 +1100 Subject: [PATCH] Write to stderr if execve fails This should be rare but should not happen silently, this way it will show in the parent process debug buffer. --- src/shell_manager.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 8f6e57ac..93a9f3fe 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -105,7 +105,7 @@ template pid_t spawn_shell(const char* shell, StringView cmdline, ConstArrayView params, ConstArrayView kak_env, - Func setup_child) + Func setup_child) noexcept { Vector envptrs; for (char** envp = environ; *envp; ++envp) @@ -128,6 +128,8 @@ pid_t spawn_shell(const char* shell, StringView cmdline, setup_child(); execve(shell, (char* const*)execparams.data(), (char* const*)envptrs.data()); + char buffer[1024]; + write(STDERR_FILENO, format_to(buffer, "execve failed: {}\n", errno)); _exit(-1); return -1; }