[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 18/44] linux-user: pause() should not pause if signal

From: riku . voipio
Subject: [Qemu-devel] [PULL 18/44] linux-user: pause() should not pause if signal pending
Date: Wed, 8 Jun 2016 16:29:59 +0300

From: Timothy E Baldwin <address@hidden>

Fix races between signal handling and the pause syscall by
reimplementing it using block_signals() and sigsuspend().
(Using safe_syscall(pause) would also work, except that the
pause syscall doesn't exist on all architectures.)

Signed-off-by: Timothy Edward Baldwin <address@hidden>
Message-id: address@hidden
[PMM: tweaked commit message]
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
 linux-user/syscall.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 639b328..aa5517c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7059,7 +7059,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 #ifdef TARGET_NR_pause /* not on alpha */
     case TARGET_NR_pause:
-        ret = get_errno(pause());
+        if (!block_signals()) {
+            sigsuspend(&((TaskState *)cpu->opaque)->signal_mask);
+        }
+        ret = -TARGET_EINTR;
 #ifdef TARGET_NR_utime

reply via email to

[Prev in Thread] Current Thread [Next in Thread]