Skip to content

gsubprocess: Globally ignore SIGPIPE

Philip Withnall requested to merge pwithnall/glib:3310-subprocess-sigpipe into main

Just like we already do in GSocket.

This is necessary when using g_subprocess_communicate() with a subprocess which calls close() on its stdin FD at some point. cat does this just before exiting, for example.

This causes a write() to the stdin pipe in the parent process to fail with EPIPE and SIGPIPE. The condition is not detectable in advance, because the close() call could happen after the GMainContext has dispatched a g_subprocess_communicate() callback.

If it weren’t for the SIGPIPE,g_subprocess_communicate() would be able to handle the EPIPE just fine. SIGPIPE seems like a default error handling path which was useful in 1980 for writing pipe-heavy command line apps, but which is more of a broken stair for writing larger modern apps which have more than one data flow path.

Signed-off-by: Philip Withnall pwithnall@gnome.org

Fixes: #3310 (closed)

Closes #3310 (closed)

Merge request reports