Skip to content

gstdio: Preserve errno in g_autofd, document async-signal safety

Simon McVittie requested to merge wip/smcv/autofd into main
  • gstdio: Preserve errno when calling g_clear_fd() from g_autofd

    g_clear_fd() can alter errno, but it's unexpected for leaving a scope to change errno.

  • gstdio: Document errno behaviour of g_clear_fd

    g_clear_fd has the same interaction with errno as g_close or most libc functions: on success it has an unspecified effect on errno, and on failure (other than programming error) it sets errno to indicate the reason for failure.

  • gstdio: Document async-signal-safety of g_clear_fd and g_autofd

    g_clear_fd wraps g_close and is async-signal-safe under essentially the same circumstances. If fd_ptr already pointed to a negative number, then g_clear_fd doesn't call g_close, and is still async-signal-safe.

    g_autofd passes a NULL error pointer to g_clear_fd, so it is async-signal-safe, as long as no programming error occurs.

  • tests: Test EBADF and errno handling when closing fds

Edited by Simon McVittie

Merge request reports