Skip to content

Ignored errors in file handling #24413

Description

@tbu-

Currently you cannot handle a potential error of the close syscall on POSIX systems, and of the CloseHandle function on Windows. This means that you cannot reliably write to files, because the errors are also silently ignored.

The man page of close(2) specifically says:

Not checking the return value of close() is a common but nevertheless serious programming error. It is quite possible that errors on a previous write(2) operation are first reported at the final close(). Not checking the return value when closing the file may lead to silent loss of data. This can especially be observed with NFS and with disk quota. Note that the return value should be used only for diagnostics. In particular close() should not be retried after an EINTR since this may cause a reused descriptor from another thread to be closed.

I couldn't find specific information for Windows, but it hinted that CloseHandle might also fail to indicate an error.

I'd like to nominate this bug for 1.0, because this might need backward-incompatible changes to have "sound" support for file writing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions