diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-03-23 22:38:54 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-03-23 22:40:10 +0000 |
commit | c3b287be74e12bdb15ed36e98d24fd42f8ee9122 (patch) | |
tree | 82a9f85685a35bf5b12e480ee6ed1abc24103dc8 /hurd/dtable.c | |
parent | a4ea18ec6cc3f1370efab09bc18c1badbf74aa13 (diff) | |
download | glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.tar.gz glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.tar.xz glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.zip |
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.
Diffstat (limited to 'hurd/dtable.c')
-rw-r--r-- | hurd/dtable.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/hurd/dtable.c b/hurd/dtable.c index 9437f8c06e..bbd3bfc892 100644 --- a/hurd/dtable.c +++ b/hurd/dtable.c @@ -189,6 +189,7 @@ ctty_new_pgrp (void) { int i; +retry: HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_dtable_lock); @@ -224,8 +225,18 @@ ctty_new_pgrp (void) /* This fd has a ctty-special port. We need a new one, to tell the io server of our different process group. */ io_t new; - if (__term_open_ctty (port, _hurd_pid, _hurd_pgrp, &new)) - new = MACH_PORT_NULL; + error_t err; + if ((err = __term_open_ctty (port, _hurd_pid, _hurd_pgrp, &new))) + { + if (err == EINTR) + { + /* Got a signal while inside an RPC of the critical section, retry again */ + __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_UNLOCK; + goto retry; + } + new = MACH_PORT_NULL; + } _hurd_port_set (&d->ctty, new); } |