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

Side by Side Diff: terminator.h

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 | « main.cc ('k') | terminator.cc » ('j') | terminator.cc » ('J')
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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TERMINATOR_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TERMINATOR_H__
7
8 #include <signal.h>
9
10 namespace chromeos_update_engine {
11
12 // A class allowing graceful delayed exit.
13 class Terminator {
14 public:
15 // Initializes the terminator and sets up signal handlers.
16 static void Init();
17
18 // Terminates the current process.
19 static void Exit();
20
21 // Set to true if the terminator should block termination requests in an
22 // attempt to block exiting.
23 static void set_exit_blocked(bool block) { exit_blocked_ = block ? 1 : 0; }
24
25 // Returns true if the system is trying to terminate the process, false
26 // otherwise. Returns true only if exit was blocked when the termination
27 // request arrived.
28 static bool exit_requested() { return exit_requested_ != 0; }
29
30 private:
31 // The signal handler.
32 static void HandleSignal(int signum);
33
34 static volatile sig_atomic_t exit_blocked_;
35 static volatile sig_atomic_t exit_requested_;
36 };
37
38 class ScopedTerminatorExitUnblocker {
39 public:
40 ~ScopedTerminatorExitUnblocker();
41 };
42
43 } // namespace chromeos_update_engine
44
45 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TERMINATOR_H__
OLDNEW
« no previous file with comments | « main.cc ('k') | terminator.cc » ('j') | terminator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698