diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-06-28 22:56:50 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-06-28 22:56:50 +1000 |
| commit | 43b72770ec5ef15723b0ee5c1901a39e23039de8 (patch) | |
| tree | 222289ccefdb101959a3926ba53b306412f7781f | |
| parent | fe57d90091ce0b288d01d21f7fe274334b15e4f9 (diff) | |
Fix wrong logic for moving filedescriptors leading to closed stdin
With this fix, tests can now use /dev/null as stdin.
Fixes #2165
| -rw-r--r-- | src/shell_manager.cc | 7 | ||||
| -rwxr-xr-x | test/run | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 3615567e..6aa2b31d 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -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) { @@ -55,7 +55,7 @@ main() { fi ui_in="${root}/${dir}/ui-in" - [ ! -f $ui_in ] && ui_in="/dev/tty" + [ ! -f $ui_in ] && ui_in="/dev/null" number_tests=$(($number_tests + 1)) touch in; cp in out |
