Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 862
    • Issues 862
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 40
    • Merge requests 40
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !3027

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

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Simon McVittie requested to merge wip/smcv/autofd into main Oct 28, 2022
  • Overview 10
  • Commits 4
  • Pipelines 5
  • Changes 3
  • 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 Oct 31, 2022 by Simon McVittie
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/smcv/autofd