From c3b287be74e12bdb15ed36e98d24fd42f8ee9122 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 23 Mar 2021 22:38:54 +0000 Subject: hurd: handle EINTR during critical sections During critical sections, signal handling is deferred and thus RPCs return EINTR, even if SA_RESTART is set. We thus have to restart the whole critical section in that case. This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to break the section in the middle. --- sysdeps/mach/hurd/setgid.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sysdeps/mach/hurd/setgid.c') diff --git a/sysdeps/mach/hurd/setgid.c b/sysdeps/mach/hurd/setgid.c index 6e0672d5e8..c6a64c9423 100644 --- a/sysdeps/mach/hurd/setgid.c +++ b/sysdeps/mach/hurd/setgid.c @@ -32,6 +32,7 @@ __setgid (gid_t gid) auth_t newauth; error_t err; +retry: HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_id.lock); err = _hurd_check_ids (); @@ -81,6 +82,9 @@ __setgid (gid_t gid) } __mutex_unlock (&_hurd_id.lock); HURD_CRITICAL_END; + if (err == EINTR) + /* Got a signal while inside an RPC of the critical section, retry again */ + goto retry; if (err) return __hurd_fail (err); -- cgit 1.4.1