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.
This commit is contained in:
parent
841ec2e588
commit
74fc52b3de
|
@ -105,7 +105,7 @@ template<typename Func>
|
||||||
pid_t spawn_shell(const char* shell, StringView cmdline,
|
pid_t spawn_shell(const char* shell, StringView cmdline,
|
||||||
ConstArrayView<String> params,
|
ConstArrayView<String> params,
|
||||||
ConstArrayView<String> kak_env,
|
ConstArrayView<String> kak_env,
|
||||||
Func setup_child)
|
Func setup_child) noexcept
|
||||||
{
|
{
|
||||||
Vector<const char*> envptrs;
|
Vector<const char*> envptrs;
|
||||||
for (char** envp = environ; *envp; ++envp)
|
for (char** envp = environ; *envp; ++envp)
|
||||||
|
@ -128,6 +128,8 @@ pid_t spawn_shell(const char* shell, StringView cmdline,
|
||||||
setup_child();
|
setup_child();
|
||||||
|
|
||||||
execve(shell, (char* const*)execparams.data(), (char* const*)envptrs.data());
|
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);
|
_exit(-1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user