Use distinguished exit status for unittests.
* Enabled a parametric exit status in Terminator::Exit().
* The unittest binary sets this exit status to 2, to distinguish it from
other exit(1) calls in the code base.
BUG=chromium-os:29841
TEST=Build, passes unit tests.
Change-Id: I2bf6a834743e513a647ed7bb2266ef095064d6bc
Reviewed-on: https://gerrit.chromium.org/gerrit/21479
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/terminator.cc b/terminator.cc
index abf57c8..6d00ddb 100644
--- a/terminator.cc
+++ b/terminator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
namespace chromeos_update_engine {
+volatile sig_atomic_t Terminator::exit_status_ = 1; // default exit status
volatile sig_atomic_t Terminator::exit_blocked_ = 0;
volatile sig_atomic_t Terminator::exit_requested_ = 0;
@@ -17,8 +18,13 @@
signal(SIGTERM, HandleSignal);
}
+void Terminator::Init(int exit_status) {
+ exit_status_ = exit_status;
+ Init();
+}
+
void Terminator::Exit() {
- exit(1);
+ exit(exit_status_);
}
void Terminator::HandleSignal(int signum) {