gh-118422: Fix run_fileexflags() test (#118429)

Don't test the undefined behavior of fileno()
on a closed file, but use fstat() as a reliable
test if the file was closed or not.
4 files changed