Fix wrong logic for moving filedescriptors leading to closed stdin
With this fix, tests can now use /dev/null as stdin. Fixes #2165
This commit is contained in:
parent
fe57d90091
commit
43b72770ec
|
@ -167,7 +167,12 @@ std::pair<String, int> ShellManager::eval(
|
|||
Pipe child_stdin{not input.empty()}, child_stdout, child_stderr;
|
||||
pid_t pid = spawn_shell(m_shell.c_str(), cmdline, shell_context.params, kak_env,
|
||||
[&child_stdin, &child_stdout, &child_stderr] {
|
||||
auto move = [](int oldfd, int newfd) { dup2(oldfd, newfd); close(oldfd); };
|
||||
auto move = [](int oldfd, int newfd)
|
||||
{
|
||||
if (oldfd == newfd)
|
||||
return;
|
||||
dup2(oldfd, newfd); close(oldfd);
|
||||
};
|
||||
|
||||
if (child_stdin.read_fd() != -1)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user