flush stdout when prompting for password (#25348)

Saw this misbehave on Linux. It was fine in Windows when I checked, but
I figured it can't hurt.
This commit is contained in:
Ryan McConnell
2025-12-17 22:52:39 -05:00
committed by araq
parent 2b450c9a9e
commit e2845e1b09

View File

@@ -909,6 +909,7 @@ when defined(windows):
## `true` otherwise.
password.setLen(0)
stdout.write(prompt)
stdout.flushFile()
let hi = createFileA("CONIN$",
GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0)
var mode = DWORD 0
@@ -936,6 +937,7 @@ else:
cur.c_lflag = cur.c_lflag and not Cflag(ECHO)
discard fd.tcSetAttr(TCSADRAIN, cur.addr)
stdout.write prompt
stdout.flushFile()
result = stdin.readLine(password)
stdout.write "\n"
discard fd.tcSetAttr(TCSADRAIN, old.addr)