Sid Shanker @RC 06/21/2018
write_to_bash(...)
data = read_from_bash(...)
write_data_to_socket(data)
new_command = read_data_from_socket()
write_to_bash(...);
write_to_bash("echo 1");
data = read_from_bash(...);
// Ignore the "1" in the output
write_data_to_socket(data);
new_command = read_data_from_socket();
$ garbage_command_that_dont_exist
$ echo 1
$ echo $? # == 0, this is WRONG
Fork into two processes, one that reads from bash only, one that reads from the socket only.
socket_fd, bash_pipe_fd;
select([socket_fd, bash_pipe_fd])
if (IS_READY(socket_fd)) {
handle_input_on_socket();
} else if (IS_READY(bash_pipe_fd)){
handle_input_on_bash_pipe();
}