aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-10-06 20:41:45 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-10-06 20:41:45 +0000
commit6faddfce5e7e803e2f456a497d8f8686952c2635 (patch)
tree260fba49fa3c9415a6513e9796d4f4406441bdc1
parentd8494ea7e2ec2238cd4a5db24208ba27d051cfc5 (diff)
downloadpaludis-6faddfce5e7e803e2f456a497d8f8686952c2635.tar.gz
paludis-6faddfce5e7e803e2f456a497d8f8686952c2635.tar.xz
Catch both SIGINT and SIGTERM.
-rw-r--r--src/output/console_install_task.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index a9d54c5..cec3afb 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -72,9 +72,9 @@ namespace
std::list<ConsoleInstallTask *> tasks;
Mutex tasks_mutex;
- void sigterm_handler(int sig) PALUDIS_ATTRIBUTE((noreturn));
+ void signal_handler(int sig) PALUDIS_ATTRIBUTE((noreturn));
- void sigterm_handler(int sig)
+ void signal_handler(int sig)
{
cout << endl;
cerr << "Caught signal " << sig << endl;
@@ -131,23 +131,26 @@ ConsoleInstallTask::ConsoleInstallTask(Environment * const env,
void
ConsoleInstallTask::execute()
{
- struct sigaction act, oldact;
- act.sa_handler = &sigterm_handler;
+ struct sigaction act, oldint, oldterm;
+ act.sa_handler = &signal_handler;
act.sa_flags = 0;
::sigemptyset(&act.sa_mask);
+ ::sigaddset(&act.sa_mask, SIGINT);
::sigaddset(&act.sa_mask, SIGTERM);
{
Lock l(tasks_mutex);
tasks.push_front(this);
- ::sigaction(SIGTERM, &act, &oldact);
+ ::sigaction(SIGINT, &act, &oldint);
+ ::sigaction(SIGTERM, &act, &oldterm);
}
InstallTask::execute();
{
Lock l(tasks_mutex);
- ::sigaction(SIGTERM, &oldact, 0);
+ ::sigaction(SIGINT, &oldint, 0);
+ ::sigaction(SIGTERM, &oldterm, 0);
tasks.remove(this);
}
}