mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 04:02:41 +00:00
Added setStdIoUnbuffered for unbuffered stdio (fixes #2146).
This commit is contained in:
@@ -2708,6 +2708,9 @@ when not defined(JS): #and not defined(nimscript):
|
||||
##
|
||||
## Default mode is readonly. Returns true iff the file could be reopened.
|
||||
|
||||
proc setStdIoUnbuffered() {.tags: [], benign.}
|
||||
## Configures `stdin`, `stdout` and `stderr` to be unbuffered.
|
||||
|
||||
proc close*(f: File) {.importc: "fclose", header: "<stdio.h>", tags: [].}
|
||||
## Closes the file.
|
||||
|
||||
|
||||
@@ -354,4 +354,9 @@ proc writeFile(filename, content: string) =
|
||||
else:
|
||||
sysFatal(IOError, "cannot open: ", filename)
|
||||
|
||||
proc setStdIoUnbuffered() =
|
||||
discard setvbuf(stdout, nil, IONBF, 0)
|
||||
discard setvbuf(stderr, nil, IONBF, 0)
|
||||
discard setvbuf(stdin, nil, IONBF, 0)
|
||||
|
||||
{.pop.}
|
||||
|
||||
@@ -14,6 +14,7 @@ Changes affecting backwards compatibility
|
||||
Library Additions
|
||||
-----------------
|
||||
|
||||
- Added ``setStdIoUnbuffered`` proc to ``system.nim`` to enable unbuffered I/O.
|
||||
|
||||
Compiler Additions
|
||||
------------------
|
||||
|
||||
Reference in New Issue
Block a user