From cac43c064c042d439e09fc5ee66a4c414a470260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 27 May 2020 21:04:19 +0200 Subject: [PATCH] Work in progress --- ghe-fast-tools/bin/ghe-fast-console | 2 ++ github-fast-env/bin/github-fast-envd | 10 +++++++--- github-fast-env/github-fast-env.rb | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ghe-fast-tools/bin/ghe-fast-console b/ghe-fast-tools/bin/ghe-fast-console index faef59a..2ad50fb 100644 --- a/ghe-fast-tools/bin/ghe-fast-console +++ b/ghe-fast-tools/bin/ghe-fast-console @@ -1,2 +1,4 @@ #!/usr/bin/env bash +stty raw -echo -icanon isig /usr/bin/github-fast-env --interactive /usr/lib/ghe-fast-tools/ghe-fast-console.rb +stty sane diff --git a/github-fast-env/bin/github-fast-envd b/github-fast-env/bin/github-fast-envd index 1efa8b7..8f3b60b 100644 --- a/github-fast-env/bin/github-fast-envd +++ b/github-fast-env/bin/github-fast-envd @@ -134,7 +134,9 @@ end def set_up_pseudoterminal(control_socket, pseudoterminal_path) $pseudoterminal_io = File.open(pseudoterminal_path, File::RDWR | File::NOCTTY) - $pseudoterminal_io.raw! + $pseudoterminal_io.sync = true + #$pseudoterminal_io.raw! + $pseudoterminal_io.cooked! $original_stderr.puts " connecting to pseudoterminal #{pseudoterminal_path}" @@ -149,7 +151,7 @@ end $original_stderr.puts "preloading common modules" -#load "/usr/lib/github-fast-env/preload.rb" +load "/usr/lib/github-fast-env/preload.rb" $original_stderr.puts "ready to serve requests" @@ -261,7 +263,9 @@ while true $original_stderr.puts " finished handling request (#{process_id})" - $pseudoterminal_io.close + if $pseudoterminal_io + $pseudoterminal_io.close + end end } diff --git a/github-fast-env/github-fast-env.rb b/github-fast-env/github-fast-env.rb index 3918cf5..8c23b9c 100644 --- a/github-fast-env/github-fast-env.rb +++ b/github-fast-env/github-fast-env.rb @@ -112,6 +112,16 @@ Signal.trap("CONT") do Process.kill("CONT", 0) end +Signal.trap("WINCH") do + if $pseudoterminal_master + $pseudoterminal_master.winsize = $stdout.winsize + end + + if $remote_process_id + Process.kill("WINCH", $remote_process_id) + end +end + def read_command ready_ios = IO.select([$control_socket], [], [], 10) @@ -171,11 +181,15 @@ if $options[:interactive] require "pty" $pseudoterminal_master, pseudoterminal_client = PTY.open - $pseudoterminal_master.raw! + #$pseudoterminal_master.raw! + $pseudoterminal_master.echo = false + $pseudoterminal_master.sync = true + $pseudoterminal_master.winsize = $stdout.winsize log "info", "opened pseudoterminal at #{pseudoterminal_client.path}" encoded_pseudoterminal_client_path = Base64.encode64(pseudoterminal_client.path).delete("\n") + pseudoterminal_client.close read_ios += [$stdin, $pseudoterminal_master] @@ -275,7 +289,7 @@ while read_ios.include?($control_socket) or read_ios.include?($pseudoterminal_ma log "warn", "received input from unknown stream" end rescue EOFError - if ready_read_io == $control_socket + if ready_read_io == $control_socket and $pseudoterminal_master $pseudoterminal_master.close_write pseudoterminal_master_closed = true end