mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
c_fflush() the rawWrite() buffer (#12987)
Stack traces on an unbuffered stderr get out of sync with line-buffered
stdout - usually on Windows terminals or CI logs. This fixes it by
calling C's fflush() on the output buffer in the procedure used for
printing stack traces.
(cherry picked from commit defaf3b5a5)
This commit is contained in:
committed by
narimiran
parent
2e9d595f92
commit
25a4026cda
@@ -142,8 +142,12 @@ proc c_realloc*(p: pointer, newsize: csize): pointer {.
|
||||
proc c_fwrite*(buf: pointer, size, n: csize, f: CFilePtr): cint {.
|
||||
importc: "fwrite", header: "<stdio.h>".}
|
||||
|
||||
proc c_fflush(f: CFilePtr): cint {.
|
||||
importc: "fflush", header: "<stdio.h>".}
|
||||
|
||||
proc rawWrite*(f: CFilePtr, s: cstring) {.compilerproc, nonReloadable, inline.} =
|
||||
# we cannot throw an exception here!
|
||||
discard c_fwrite(s, 1, s.len, f)
|
||||
discard c_fflush(f)
|
||||
|
||||
{.pop.}
|
||||
|
||||
Reference in New Issue
Block a user