Closed xinhaoyuan closed 5 years ago
Example:
test_empty_data() -> {ok, P, I} = exec:run("/bin/bash --norc -i", [stdin, stdout, pty, monitor]), exec:send(I, <<>>), exec:send(I, <<"exit\n">>), ?receiveMatch({'DOWN', _, process, P, normal}, 1000).
One way to fix it is simply ignoring any zero-length input. Here is my patch:
diff --git a/c_src/exec.cpp b/c_src/exec.cpp index 405b3f5..752e371 100644 --- a/c_src/exec.cpp +++ b/c_src/exec.cpp @@ -442,6 +442,13 @@ bool process_command() break; } + if (data.size() == 0) { + if (debug) { + fprintf(stderr, "Warning: ignore empty input.\r\n"); + } + break; + } + it->second.stdin_queue.push_front(data); process_pid_input(it->second); break;
Thank you. Fixed.
Example:
One way to fix it is simply ignoring any zero-length input. Here is my patch: