aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-04-20 00:25:22 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-04-20 00:25:22 +0000
commit3c8bf22e5452bd14c3da7bb66f6b0de810295a18 (patch)
treecda10a725118ee2106d206be5d156a8521b36778
parent191ab9b8b55206804f967b22ed4159c2b24e26a4 (diff)
downloadpaludis-3c8bf22e5452bd14c3da7bb66f6b0de810295a18.tar.gz
paludis-3c8bf22e5452bd14c3da7bb66f6b0de810295a18.tar.xz
Make Ctrl-C behave better.
-rw-r--r--paludis/util/system.cc20
-rw-r--r--src/output/console_install_task.cc2
2 files changed, 12 insertions, 10 deletions
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index 8c94b41..5349755 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -476,14 +476,20 @@ paludis::run_command(const Command & cmd)
/* The pid that waits for the exec pid and then writes to the done pipe. */
/* On SIGINT or SIGTERM, just output a notice. */
- struct sigaction act;
+ struct sigaction act, old_act;
act.sa_handler = &wait_handler;
- act.sa_flags = 0;
+ act.sa_flags = SA_RESTART;
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGINT);
sigaddset(&act.sa_mask, SIGTERM);
- sigaction(SIGINT, &act, 0);
- sigaction(SIGTERM, &act, 0);
+
+ sigaction(SIGINT, 0, &old_act);
+ if (SIG_DFL != old_act.sa_handler && SIG_IGN != old_act.sa_handler)
+ sigaction(SIGINT, &act, 0);
+ sigaction(SIGTERM, 0, &old_act);
+ if (SIG_DFL != old_act.sa_handler && SIG_IGN != old_act.sa_handler)
+ sigaction(SIGTERM, &act, 0);
+
#ifdef PALUDIS_ENABLE_THREADS
if (0 != pthread_sigmask(SIG_UNBLOCK, &intandterm, 0))
std::cerr << "pthread_sigmask failed: " + stringify(strerror(errno)) + "'" << std::endl;
@@ -524,16 +530,12 @@ paludis::run_command(const Command & cmd)
stderr_close_fd = -1;
int ret(-1);
- bool repeat(true);
- while (repeat)
+ while (true)
{
if (-1 == waitpid(child_child, &status, 0))
{
if (errno == EINTR)
- {
std::cerr << "wait failed: '" + stringify(strerror(errno)) + "', trying once more" << std::endl;
- repeat = false;
- }
else
{
std::cerr << "wait failed: '" + stringify(strerror(errno)) + "'" << std::endl;
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index fdb4dfe..8ca36da 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -95,7 +95,7 @@ namespace
}
cerr << endl;
cerr << "Exiting with failure" << endl;
- std::exit(EXIT_FAILURE);
+ _exit(EXIT_FAILURE);
}
}