aboutsummaryrefslogtreecommitdiffhomepage
path: root/proc.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-12-29 01:04:13 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-12-29 01:04:13 -0800
commite340baf6ccb9325073dbb10bf96ac911131c5960 (patch)
treef9ad0f263f864de2a1f5e79a43b361a2da2938fd /proc.cpp
parent182faca2e5ddff768988734b6d6b4b06d7194763 (diff)
Remove useless signal-checking loop in job_continue
This loop has always been nonsense.
Diffstat (limited to 'proc.cpp')
-rw-r--r--proc.cpp96
1 files changed, 38 insertions, 58 deletions
diff --git a/proc.cpp b/proc.cpp
index 1c887c62..649fc08a 100644
--- a/proc.cpp
+++ b/proc.cpp
@@ -83,11 +83,6 @@ Some of the code in this file is based on code from the Glibc manual.
*/
static int last_status=0;
-/**
- Signal flag
-*/
-static sig_atomic_t got_signal=0;
-
bool job_list_is_empty(void)
{
ASSERT_IS_MAIN_THREAD();
@@ -647,7 +642,6 @@ void job_handle_signal(int signal, siginfo_t *info, void *con)
{
/* This is the only place that this generation count is modified. It's OK if it overflows. */
s_sigchld_generation_count += 1;
- got_signal = 1;
}
/* Given a command like "cat file", truncate it to a reasonable length */
@@ -1228,71 +1222,57 @@ void job_continue(job_t *j, bool cont)
if (job_get_flag(j, JOB_FOREGROUND))
{
- int quit = 0;
+ bool quit = false;
/*
- Wait for job to report. Looks a bit ugly because it has to
- handle the possibility that a signal is dispatched while
- running job_is_stopped().
+ Wait for job to report.
*/
- while (!quit)
+ while (! job_is_stopped(j) && ! job_is_completed(j))
{
- do
- {
- got_signal = 0;
- quit = job_is_stopped(j) || job_is_completed(j);
- }
- while (got_signal && !quit);
-
- if (!quit)
- {
-
// debug( 1, L"select_try()" );
- switch (select_try(j))
+ switch (select_try(j))
+ {
+ case 1:
{
- case 1:
- {
- read_try(j);
- process_mark_finished_children(false);
- break;
- }
-
- case 0:
- {
- /* No FDs are ready. Look for finished processes. */
- process_mark_finished_children(false);
- break;
- }
+ read_try(j);
+ process_mark_finished_children(false);
+ break;
+ }
+
+ case 0:
+ {
+ /* No FDs are ready. Look for finished processes. */
+ process_mark_finished_children(false);
+ break;
+ }
- case -1:
+ case -1:
+ {
+ /*
+ If there is no funky IO magic, we can use
+ waitpid instead of handling child deaths
+ through signals. This gives a rather large
+ speed boost (A factor 3 startup time
+ improvement on my 300 MHz machine) on
+ short-lived jobs.
+ */
+ int processed = process_mark_finished_children(true);
+ if (processed < 0)
{
/*
- If there is no funky IO magic, we can use
- waitpid instead of handling child deaths
- through signals. This gives a rather large
- speed boost (A factor 3 startup time
- improvement on my 300 MHz machine) on
- short-lived jobs.
+ This probably means we got a
+ signal. A signal might mean that the
+ terminal emulator sent us a hup
+ signal to tell is to close. If so,
+ we should exit.
*/
- int processed = process_mark_finished_children(true);
- if (processed < 0)
+ if (reader_exit_forced())
{
- /*
- This probably means we got a
- signal. A signal might mean that the
- terminal emulator sent us a hup
- signal to tell is to close. If so,
- we should exit.
- */
- if (reader_exit_forced())
- {
- quit = 1;
- }
-
+ quit = 1;
}
- break;
- }
+ }
+ break;
}
}
}