Skip to content

Backport !2947 “gspawn: avoid race due to retry with EINTR on close()” to glib-2-74

Retry on EINTR is wrong on many OS, including Linux. See the comment in g_close() why that is.

As we cannot use g_close() after fork, we had safe_close(). This had the wrong retry loop on EINTR. Drop that.

This was especially problematic since commit 6f462942 ('gspawn: Don’t use g_close() in async-signal-safe context'). Before, safe_close() was only called after fork, where there is only one thread and there is no concern about a race.

This patch only exists for easier backporting of the bugfix. The code will be reworked further next.

Fixes: 6f462942 ('gspawn: Don’t use g_close() in async-signal-safe context')


Backport of !2947 (merged) to glib-2-74. I’ve modified the commit which changes g_close() to drop the documentation changes, since we don’t want to add additional API guarantees in a stable release series. The behaviour changes to make it async-signal-safe have been preserved, but the changes to add the g_critical() warnings have been dropped, as they could end up being disruptive to clients in a stable release cycle.

Merge request reports