From 38db12fbccbe35b90c159c9727a8adfcf89dac13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Sun, 16 May 2021 17:07:19 +0200 Subject: [PATCH] Direct non-captured output to the terminal (#273) --- lib/livebook/runtime/elixir_standalone.ex | 5 ++++- lib/livebook/runtime/mix_standalone.ex | 6 ++++-- lib/livebook/runtime/standalone_init.ex | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/livebook/runtime/elixir_standalone.ex b/lib/livebook/runtime/elixir_standalone.ex index ac6a1e1f3..84932032e 100644 --- a/lib/livebook/runtime/elixir_standalone.ex +++ b/lib/livebook/runtime/elixir_standalone.ex @@ -55,7 +55,10 @@ defmodule Livebook.Runtime.ElixirStandalone do defp start_elixir_node(elixir_path, node_name, eval, argv) do # Here we create a port to start the system process in a non-blocking way. Port.open({:spawn_executable, elixir_path}, [ - :binary, + # We don't communicate with the system process via stdio, + # contrarily, we want any non-captured output to go directly + # to the terminal + :nouse_stdio, :hide, args: elixir_flags(node_name) ++ ["--eval", eval, "--" | Enum.map(argv, &to_string/1)] ]) diff --git a/lib/livebook/runtime/mix_standalone.ex b/lib/livebook/runtime/mix_standalone.ex index 9aff08735..a01ac9765 100644 --- a/lib/livebook/runtime/mix_standalone.ex +++ b/lib/livebook/runtime/mix_standalone.ex @@ -90,8 +90,10 @@ defmodule Livebook.Runtime.MixStandalone do defp start_elixir_mix_node(elixir_path, node_name, eval, argv, project_path) do # Here we create a port to start the system process in a non-blocking way. Port.open({:spawn_executable, elixir_path}, [ - :binary, - :stderr_to_stdout, + # We don't communicate with the system process via stdio, + # contrarily, we want any non-captured output to go directly + # to the terminal + :nouse_stdio, :hide, cd: project_path, args: diff --git a/lib/livebook/runtime/standalone_init.ex b/lib/livebook/runtime/standalone_init.ex index af934c0cd..d31e8c1e0 100644 --- a/lib/livebook/runtime/standalone_init.ex +++ b/lib/livebook/runtime/standalone_init.ex @@ -39,7 +39,9 @@ defmodule Livebook.Runtime.StandaloneInit do # Minimize schedulers busy wait threshold, # so that they go to sleep immediately after evaluation. # Enable ANSI escape codes as we handle them with HTML. - "+sbwt none +sbwtdcpu none +sbwtdio none -elixir ansi_enabled true", + # Disable stdin, so that the system process never tries to read + # any input from the terminal. + "+sbwt none +sbwtdcpu none +sbwtdio none -elixir ansi_enabled true -noinput", # Make the node hidden, so it doesn't automatically join the cluster "--hidden", # Use the cookie in Livebook