Github user sanhex commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-server/pull/118#discussion_r146078760
--- Diff: src/protocols/ssh/client.c ---
@@ -70,8 +70,14 @@ int guac_ssh_client_free_handler(guac_client* client) {
/* Free terminal (which may still be using term_channel) */
if (ssh_client->term != NULL) {
- guac_terminal_free(ssh_client->term);
+ /* Close user input pipe to stop reading in ssh_input_thread */
+ close(ssh_client->term->stdin_pipe_fd[1]);
+ close(ssh_client->term->stdin_pipe_fd[0]);
+ ssh_client->term->stdin_pipe_fd[1] = -1;
+ ssh_client->term->stdin_pipe_fd[0] = -1;
+
--- End diff --
The problem here is the pipe is blocking. The call
guac_terminal_read_stdin() in ssh_input_thread() will never return when there
is no data in the pipe after ssh disconnecting. Another option is setting the
pipe fds to non-blocking and tweaking the below callers to read and sleep.
./protocols/telnet/telnet.c:267: while ((bytes_read =
guac_terminal_read_stdin(telnet_client->term, buffer, sizeof(buffer))) > 0) {
./protocols/ssh/ssh.c:161: while ((bytes_read =
guac_terminal_read_stdin(ssh_client->term, buffer, sizeof(buffer))) > 0) {
./terminal/terminal.c:622: while (guac_terminal_read_stdin(terminal,
&in_byte, 1) == 1) {
---