From c01683bea012d2ee15e325fac7177b920f23fea1 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Tue, 6 Jan 2015 14:55:26 -0800 Subject: Fix sigchainlib's implementation of sigaction Correctly handles the case when old_action == new_action Bug: 18740478 Change-Id: I97092318439e4f6f0a2513d4336496c72f8c5599 (cherry picked from commit 797a29b334f2d311135602bf5204ae8b890f4a14) --- sigchainlib/sigchain.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sigchainlib/sigchain.cc') diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc index 601e3210a9..2eb518c531 100644 --- a/sigchainlib/sigchain.cc +++ b/sigchainlib/sigchain.cc @@ -170,12 +170,13 @@ extern "C" int sigaction(int signal, const struct sigaction* new_action, struct // Note that we check that the signal number is in range here. An out of range signal // number should behave exactly as the libc sigaction. if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed()) { - if (old_action != NULL) { - *old_action = user_sigactions[signal].GetAction(); - } + struct sigaction saved_action = user_sigactions[signal].GetAction(); if (new_action != NULL) { user_sigactions[signal].SetAction(*new_action, false); } + if (old_action != NULL) { + *old_action = saved_action; + } return 0; } -- cgit v1.2.3