From d515bebdba37cb49f56b2c53eaea809352e8ce11 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Mon, 19 Sep 2022 03:14:44 +0200 Subject: [PATCH] pararun: MacOS, weird error 259 when accumulating pipes or processes --- helpers/pararun.nim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/helpers/pararun.nim b/helpers/pararun.nim index 6947784..2f50aaa 100644 --- a/helpers/pararun.nim +++ b/helpers/pararun.nim @@ -79,6 +79,7 @@ proc enqueuePendingCommands(wq: WorkQueue) {.async.} = let p = cmd.startProcess( options = {poStdErrToStdOut, poUsePath, poEvalCommand} ) + p.inputHandle.close() asyncCheck wq.sem.releaseOnProcessExit(p) wq.outputQueue.putNoWait((cmd, p)) @@ -99,14 +100,14 @@ proc flushCommandsOutput(wq: WorkQueue) {.async.} = let charsWritten = stdout.writeBuffer(wq.lineBuf[0].addr, charsRead) doAssert charsRead == charsWritten - let exitCode = await p.waitForExit() - if exitCode != 0: - quit "Command #" & $id & " exited with error " & $exitCode, exitCode - - # p.close() is not exposed :/ - p.inputHandle.close() p.outputHandle.close() - p.errorHandle.close() + + let exitCode = p.peekExitCode() + if exitCode != 0: + echo "==== Custom stacktrace ====" + writeStackTrace() + echo "==== Custom stacktrace ====" + quit "Command #" & $id & " exited with error " & $exitCode, exitCode id += 1