Skip to content

Ensure g_subprocess_communicate_async() never blocks

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)

Merge request reports