std.os.fsync
, File.sync
hit unreachable EINVAL for special files
#17950
Labels
bug
Observed behavior contradicts documented or intended behavior
standard library
This issue involves writing Zig code for the standard library.
Milestone
Zig Version
0.11.0
Steps to Reproduce and Observed Behavior
On x86_64 Linux:
Expected Behavior
(Some discussion about this in general at #10776)
Currently,
std.os.fsync
enters unreachable code iffsync
returns EINVAL. This means for files like/dev/null
, it panics.It seems reasonable to me that an arbitrary file may be opened (eg. from command line arguments), and that this file could be special. It also seems reasonable that the program may try to sync writes to ensure that data is correctly written to the file.
However, these are currently incompatible without somehow checking that the file is special, and I don't know of a function to check this in
std
(please correct me if there is one).I think that returning the error would be more elegant than having this explicit check before the call.
The text was updated successfully, but these errors were encountered: