Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'echo' raise IOErrors when appropriate #16367

Merged
merged 7 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/system/io.nim
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,10 @@ when declared(stdout):
proc flockfile(f: File) {.importc, nodecl.}
proc funlockfile(f: File) {.importc, nodecl.}
flockfile(stdout)
defer: funlockfile(stdout)
when defined(windows) and compileOption("threads"):
acquireSys echoLock
defer: releaseSys echoLock
for s in args:
when defined(windows):
writeWindows(stdout, s)
Expand All @@ -805,10 +807,6 @@ when declared(stdout):
checkErr(stdout)
if c_fflush(stdout) != 0:
checkErr(stdout)
when stdOutLock:
funlockfile(stdout)
when defined(windows) and compileOption("threads"):
releaseSys echoLock


when defined(windows) and not defined(nimscript) and not defined(js):
Expand Down
10 changes: 10 additions & 0 deletions tests/exception/t16366.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
discard """
action: run
exitcode: 1
iffy marked this conversation as resolved.
Show resolved Hide resolved
targets: "c cpp"
iffy marked this conversation as resolved.
Show resolved Hide resolved
"""

echo "foo1"
close stdout
doAssertRaises(IOError):
echo "foo"