2 ms·
Arguably, one should call `flush()` on the file first. Resource deallocation must always succeed; otherwise a lot of invariants break. This is why Zig's close m
by trashburger 2y ago
Arguably, one should call `flush()` on the file first. Resource deallocation must always succeed; otherwise a lot of invariants break. This is why Zig's close method[0] ignores errors (with the exception of `EBADF`).
[0]: https://github.com/ziglang/zig/blob/fb0028a0d7b43a2a5dd05f075ded22746f92faf6/lib/std/posix.zig#L263 https://github.com/ziglang/zig/blob/fb0028a0d7b43a2a5dd05f07...
- AndyKelley 2y agoNote that the "unreachable" there is equivalent to assert(error != EBADF), so really it's not even an exception, it's just helpful to crash there when debugging if you get that error. Important to understand that EBADF is not a catchable error because the kernel may have already reused that file descriptor for something else, in which case you wouldn't get EBADF, you would close an unrelated file descriptor.