Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: terminator.cc

Issue 5245002: AU: Exit with status 1 through the Terminator. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | terminator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/terminator.h" 5 #include "update_engine/terminator.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 namespace chromeos_update_engine { 9 namespace chromeos_update_engine {
10 10
11 volatile sig_atomic_t Terminator::exit_blocked_ = 0; 11 volatile sig_atomic_t Terminator::exit_blocked_ = 0;
12 volatile sig_atomic_t Terminator::exit_requested_ = 0; 12 volatile sig_atomic_t Terminator::exit_requested_ = 0;
13 13
14 void Terminator::Init() { 14 void Terminator::Init() {
15 exit_blocked_ = 0; 15 exit_blocked_ = 0;
16 exit_requested_ = 0; 16 exit_requested_ = 0;
17 signal(SIGTERM, HandleSignal); 17 signal(SIGTERM, HandleSignal);
18 } 18 }
19 19
20 void Terminator::Exit() { 20 void Terminator::Exit() {
21 exit(0); 21 exit(1);
22 } 22 }
23 23
24 void Terminator::HandleSignal(int signum) { 24 void Terminator::HandleSignal(int signum) {
25 if (exit_blocked_ == 0) { 25 if (exit_blocked_ == 0) {
26 Exit(); 26 Exit();
27 } 27 }
28 exit_requested_ = 1; 28 exit_requested_ = 1;
29 } 29 }
30 30
31 ScopedTerminatorExitUnblocker::~ScopedTerminatorExitUnblocker() { 31 ScopedTerminatorExitUnblocker::~ScopedTerminatorExitUnblocker() {
32 Terminator::set_exit_blocked(false); 32 Terminator::set_exit_blocked(false);
33 if (Terminator::exit_requested()) { 33 if (Terminator::exit_requested()) {
34 Terminator::Exit(); 34 Terminator::Exit();
35 } 35 }
36 } 36 }
37 37
38 } // namespace chromeos_update_engine 38 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « no previous file | terminator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698