Open amano-kenji opened 4 months ago
I don't think Janet has a way at the moment, but I seem to recall one can close all the std files, then reopen them by file descriptors. If there was a way to operate `/openon file descriptors (integers) for I think FD 0, 1, and 2 - that would solve the issue. If what was opened was returned as a stream instead of a file (like how
os/open` does) then it'd be async-able.
Building on this, I have recently pushed code that extends os/exit
with a force
parameter which allows calling _exit
instead of exit
. This circumvents the issue where exit
needs to flush the standard streams before completing, which in some cases may fail. Unfortunately, this seems to be required by the C standard as detailed here - https://en.cppreference.com/w/c/program/exit ("all C streams are flushed and closed") The async streams though may be the better solutions.
Is it difficult to implement stdin
as core/stream
?
(os/exit 1 true)
can be a way to solve this issue, too.
Right now,
stdin
is a file. I have to usefile/read
in a thread.I can't kill the program with
(os/exit 1)
which is blocked byfile/read
.