From aa83c173593e6e72c8ec5121550418efb533dadd Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 1 Mar 2018 14:26:49 -0800 Subject: [PATCH] sys_util: register_signal_handler should use SA_RESTART On Linux, signal handlers installed with signal() will restart interrupted system calls. When we moved to using sigaction() we forgot to specify SA_RESTART and so we started experiencing returns from read write system calls with EINTR, which throws off some of the code. Instead of sprinkling "handle_eintr" everywhere, let's restore the old behavior. TEST=cargo test --features plugin; cargo test -p sys_util BUG=chromium:800626 Change-Id: I24c23069ad4c9e7be8c484ee4c57f67451a2944d Signed-off-by: Dmitry Torokhov Reviewed-on: https://chromium-review.googlesource.com/944848 Reviewed-by: Zach Reizner --- sys_util/src/signal.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys_util/src/signal.rs b/sys_util/src/signal.rs index 5b256c899c..5196e20acb 100644 --- a/sys_util/src/signal.rs +++ b/sys_util/src/signal.rs @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use libc::{c_int, sigaction, timespec, +use libc::{c_int, sigaction, SA_RESTART, timespec, sigset_t, siginfo_t, sigaddset, sigemptyset, sigismember, sigpending, sigtimedwait, pthread_t, pthread_kill, pthread_sigmask, @@ -75,6 +75,7 @@ pub unsafe fn register_signal_handler( } let mut sigact: sigaction = mem::zeroed(); + sigact.sa_flags = SA_RESTART; sigact.sa_sigaction = handler as *const () as usize; let ret = sigaction(num, &sigact, null_mut());