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

Side by Side Diff: terminator.cc

Issue 3608015: AU: Catch terminate signals and block exit if necessary. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: typo Created 10 years, 2 months 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 | « terminator.h ('k') | testrunner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
adlr 2010/10/07 17:26:05 it might be a bit more efficient to have the OS ki
petkov 2010/10/07 17:29:31 Yeah, thought about this. It seems better to exit
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "update_engine/terminator.h"
6
7 #include <cstdlib>
8
9 namespace chromeos_update_engine {
10
11 volatile sig_atomic_t Terminator::exit_blocked_ = 0;
12 volatile sig_atomic_t Terminator::exit_requested_ = 0;
13
14 void Terminator::Init() {
15 signal(SIGTERM, HandleSignal);
16 }
17
18 void Terminator::Exit() {
19 exit(0);
20 }
21
22 void Terminator::HandleSignal(int signum) {
23 if (exit_blocked_ == 0) {
24 Exit();
25 }
26 exit_requested_ = 1;
27 }
28
29 ScopedTerminatorExitUnblocker::~ScopedTerminatorExitUnblocker() {
30 Terminator::set_exit_blocked(false);
31 if (Terminator::exit_requested()) {
32 Terminator::Exit();
33 }
34 }
35
36 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « terminator.h ('k') | testrunner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698