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
  • !1618

Backport !1617 “Ensure g_subprocess_communicate_async() never blocks” to glib-2-64

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Philip Withnall requested to merge pwithnall/glib:backport-1617-subprocess-blocking-glib-2-64 into glib-2-64 Aug 17, 2020
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

It turns out that our async write operation implementation is broken on non-O_NONBLOCK pipes, because the default async write implementation calls write() after poll() said there were some space. However, the semantics of pipes is that unless O_NONBLOCK is set then the write will block if the passed in write count is larger than the available space.

This caused a deadlock in #2182 (closed) due to the loop-back of the app stdout to the parent, but even without such a deadlock it is a problem that we may block the mainloop at all.

In the particular case of g_subprocess_communicate() we have full control of the pipes after starting the app, so it is safe to enable O_NONBLOCK (i.e. we can ensure all the code using the fd after this can handle non-blocking mode).

This fixes #2182 (closed)


Trivial backport of !1617 (merged) to glib-2-64.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: backport-1617-subprocess-blocking-glib-2-64