mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +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.
This commit is contained in:
committed by
Clyybber
parent
8d1a7db6ea
commit
defaf3b5a5
@@ -142,8 +142,12 @@ proc c_realloc*(p: pointer, newsize: csize_t): pointer {.
|
||||
proc c_fwrite*(buf: pointer, size, n: csize_t, 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, cast[csize_t](s.len), f)
|
||||
discard c_fflush(f)
|
||||
|
||||
{.pop.}
|
||||
|
||||
Reference in New Issue
Block a user