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 <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/944848
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Dmitry Torokhov 2018-03-01 14:26:49 -08:00 committed by chrome-bot
parent 43724a239b
commit aa83c17359

View file

@ -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());