Remove useless signal-checking loop in job_continue

This loop has always been nonsense.
This commit is contained in:
ridiculousfish 2014-12-29 01:04:13 -08:00
parent 182faca2e5
commit e340baf6cc

View File

@ -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;
}
}
}