summaryrefslogtreecommitdiffstats
path: root/src/subprocess_test.cc
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2015-04-29 07:33:37 (GMT)
committerNicolas Despres <nicolas.despres@gmail.com>2015-09-20 13:04:42 (GMT)
commit23de4b25e9285d24cfa21fbed5acd105492866d8 (patch)
treeb5e45ec170acfe31e030573def3b4094f22dd113 /src/subprocess_test.cc
parenta48434493d69085aa6fc0c002180ace555cad592 (diff)
downloadNinja-23de4b25e9285d24cfa21fbed5acd105492866d8.zip
Ninja-23de4b25e9285d24cfa21fbed5acd105492866d8.tar.gz
Ninja-23de4b25e9285d24cfa21fbed5acd105492866d8.tar.bz2
Cleanup build on SIGHUP.
SIGHUP is sent when the connection hang up (i.e. when the terminal window is closed or the ssh connection is closed).
Diffstat (limited to 'src/subprocess_test.cc')
-rw-r--r--src/subprocess_test.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc
index 07cc52f..066bbb7 100644
--- a/src/subprocess_test.cc
+++ b/src/subprocess_test.cc
@@ -122,6 +122,30 @@ TEST_F(SubprocessTest, InterruptParentWithSigTerm) {
ASSERT_FALSE("We should have been interrupted");
}
+TEST_F(SubprocessTest, InterruptChildWithSigHup) {
+ Subprocess* subproc = subprocs_.Add("kill -HUP $$");
+ ASSERT_NE((Subprocess *) 0, subproc);
+
+ while (!subproc->Done()) {
+ subprocs_.DoWork();
+ }
+
+ EXPECT_EQ(ExitInterrupted, subproc->Finish());
+}
+
+TEST_F(SubprocessTest, InterruptParentWithSigHup) {
+ Subprocess* subproc = subprocs_.Add("kill -HUP $PPID ; sleep 1");
+ ASSERT_NE((Subprocess *) 0, subproc);
+
+ while (!subproc->Done()) {
+ bool interrupted = subprocs_.DoWork();
+ if (interrupted)
+ return;
+ }
+
+ ASSERT_FALSE("We should have been interrupted");
+}
+
// A shell command to check if the current process is connected to a terminal.
// This is different from having stdin/stdout/stderr be a terminal. (For
// instance consider the command "yes < /dev/null > /dev/null 2>&1".