restore terminal echoing after pressing Ctrl+C at a password prompt (#2412)
This commit is contained in:
parent
26c56c2800
commit
683edbff7a
|
@ -1916,6 +1916,8 @@ programMain:
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||||
setupForeignThreadGc()
|
setupForeignThreadGc()
|
||||||
|
# in case a password prompt disabled echoing
|
||||||
|
resetStdin()
|
||||||
echo "" # If we interrupt during an interactive prompt, this
|
echo "" # If we interrupt during an interactive prompt, this
|
||||||
# will move the cursor to the next line
|
# will move the cursor to the next line
|
||||||
notice "Shutting down after having received SIGINT"
|
notice "Shutting down after having received SIGINT"
|
||||||
|
|
|
@ -20,6 +20,9 @@ import
|
||||||
./spec/[datatypes, crypto, helpers], beacon_clock, filepath,
|
./spec/[datatypes, crypto, helpers], beacon_clock, filepath,
|
||||||
./networking/eth2_network
|
./networking/eth2_network
|
||||||
|
|
||||||
|
when defined(posix):
|
||||||
|
import termios
|
||||||
|
|
||||||
proc setupStdoutLogging*(logLevel: string) =
|
proc setupStdoutLogging*(logLevel: string) =
|
||||||
when compiles(defaultChroniclesStream.output.writer):
|
when compiles(defaultChroniclesStream.output.writer):
|
||||||
defaultChroniclesStream.outputs[0].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.
|
# Brute-force, but ensure it's reliable enough to run in CI.
|
||||||
quit(0)
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue