close · shipping · also close(), close(2)

close

close is an operation that releases a file descriptor so its number can be allocated again.

A zero return does not establish file durability. Check close errors as well as the preceding writes and synchronization: delayed write errors can surface at close. [1]

Linux releases a valid descriptor before later close processing can fail; retrying the same number can therefore close an unrelated file that reused it. EBADF instead means the descriptor was invalid. This release order is visible in the v6.12 syscall. [3]

POSIX.1-2024 differs from Linux for EINTR: where that error is permitted, the descriptor remains open, whereas EINPROGRESS means it was closed with completion continuing asynchronously. For the descriptor left open after EINTR, POSIX leaves it unspecified whether calls other than close or posix_close can use it without error. Linux also releases the descriptor on EINTR. Recovery code must follow its target platform's contract. [2] [1]

Relations

related
file-descriptor, open-file-description, fsync, fdatasync, writeback-error

Limitations

Citations

  1. Linux man-pages 6.19: close(2) (accessed 2026-10-17)
  2. POSIX.1-2024: close(), DESCRIPTION and RATIONALE (accessed 2026-10-17)
  3. Linux v6.12: close syscall releases the descriptor before flushing (accessed 2026-10-17)

Further reading

  1. Hesela: Closing a descriptor is not a durability acknowledgement (accessed 2026-10-17)

JSON: /data/terms/close.json