diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 32d5b8b1a..c00ec9321 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1916,6 +1916,8 @@ programMain: when defined(windows): # workaround for https://github.com/nim-lang/Nim/issues/4057 setupForeignThreadGc() + # in case a password prompt disabled echoing + resetStdin() echo "" # If we interrupt during an interactive prompt, this # will move the cursor to the next line notice "Shutting down after having received SIGINT" diff --git a/beacon_chain/nimbus_binary_common.nim b/beacon_chain/nimbus_binary_common.nim index 492d50e44..164070aa6 100644 --- a/beacon_chain/nimbus_binary_common.nim +++ b/beacon_chain/nimbus_binary_common.nim @@ -20,6 +20,9 @@ import ./spec/[datatypes, crypto, helpers], beacon_clock, filepath, ./networking/eth2_network +when defined(posix): + import termios + proc setupStdoutLogging*(logLevel: string) = when compiles(defaultChroniclesStream.output.writer): defaultChroniclesStream.outputs[0].writer = @@ -107,3 +110,13 @@ proc checkIfShouldStopAtEpoch*(scheduledSlot: Slot, stopAtEpoch: uint64) = # Brute-force, but ensure it's reliable enough to run in CI. quit(0) + +proc resetStdin*() = + when defined(posix): + # restore echoing, in case it was disabled by a password prompt + let fd = stdin.getFileHandle() + var attrs: Termios + discard fd.tcGetAttr(attrs.addr) + attrs.c_lflag = attrs.c_lflag or Cflag(ECHO) + discard fd.tcSetAttr(TCSANOW, attrs.addr) +