Closed straight-shoota closed 1 month ago
Interestingly, Process::Redirect::Close
does not actually close the file descriptor. It only passes the null device (i.e. it's equivalent to crystal < /dev/null
).
A closed file descriptor equivalent to the shell redirection apparently <&-
has different semantics.
This issue has been mentioned on Crystal Forum. There might be relevant details there:
https://forum.crystal-lang.org/t/unable-to-get-info-bad-file-descriptor-io-error/6820/4
This issue has been mentioned on Crystal Forum. There might be relevant details there:
https://forum.crystal-lang.org/t/unable-to-get-info-bad-file-descriptor-io-error/6820/12
As part of programm startup, the Crystal runtime initializes handles for the three standard streams. If such a stream is already closed, the runtime crashes.
This affects any Crystal program which uses
STDIN
somehow (i.e. the constant is initialized).A minimal reproduction is
crystal <&-
(the shell redirection<&-
instructs that stdin is to be closed). This results in the following error:The same error does not appear when passing a closed output file descriptor (
crystal >&-
).I'm not sure how to reproduce in pure Crystal yet. Passing a closed
IO
toProcess.run
errors on the invoking process (Closed stream
fromProcess#copy_io
). This needs to be fixed as well.This was originally reported in https://forum.crystal-lang.org/t/unable-to-get-info-bad-file-descriptor-io-error/6820