wren-lang / wren-cli

A command line tool for the Wren programming language
MIT License
129 stars 30 forks source link

io.Stdout.flush() ignores output errors rather than ensuring output buffers get written #59

Open guenther-brunthaler opened 3 years ago

guenther-brunthaler commented 3 years ago

The fflush() C API call in stdoutFlush(WrenVM*) should check the return code and throw an exception if it is nonzero.

In particular

$ cat test.wren 
import "io" for Stdout
System.write("Hello, world!\n")
Stdout.flush()

$ wren-cli test.wren > /dev/full ; echo "return code = $?"
return code = 0

There is currently no error message to indicate the output error, nor a failure return code.

joshgoebel commented 3 years ago

@guenther-brunthaler Could you test?