try atEnd?

This commit is contained in:
Daylin Morgan 2025-02-11 12:58:30 -06:00
parent acbe72fa2e
commit 5a954a92bf
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -45,11 +45,12 @@ proc runCmdCapt*(
errstrm = peekableErrorStream p errstrm = peekableErrorStream p
result.exitCode = -1 result.exitCode = -1
var line: string var line: string
# BUG: the readLine's hang if there is no data. would peek also hang?
while true: while true:
if CaptStdout in capture and not isNil(outstrm): if CaptStdout in capture and not outstrm.atEnd():
if outstrm.readLine(line): if outstrm.readLine(line):
result.stdout.add line & '\n' result.stdout.add line & '\n'
if CaptStderr in capture and not isNil(errstrm): if CaptStderr in capture and not errstrm.atEnd():
if errstrm.readLine(line): if errstrm.readLine(line):
result.stderr.add line & '\n' result.stderr.add line & '\n'
result.exitCode = peekExitCode(p) result.exitCode = peekExitCode(p)