mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
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):
|
||||
# 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"
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user