Change the foregrounf/background code a bit, fixes bug where mulktiple jobs want foreground status. Is this fix enough or are there still corner cases?

darcs-hash:20060118124248-ac50b-cbbddb8c6dad1f44826050395cda647fa9348f0f.gz
This commit is contained in:
axel
2006-01-18 22:42:48 +10:00
parent e15c7fd7e0
commit 05736978bb
7 changed files with 44 additions and 36 deletions

26
proc.c
View File

@@ -846,22 +846,6 @@ static void read_try( job_t *j )
}
}
/**
Test if a specified job contains external commands
\param j the job to test
*/
static int job_is_external( job_t *j )
{
process_t *p;
for( p=j->first_process; p; p=p->next )
{
if( p->type == EXTERNAL )
return 1;
}
return 0;
}
void job_continue (job_t *j, int cont)
{
@@ -873,7 +857,7 @@ void job_continue (job_t *j, int cont)
first_job = j;
j->notified = 0;
debug( 3,
debug( 4,
L"Continue on job %d (%ls), %ls, %ls",
j->job_id,
j->command,
@@ -882,7 +866,7 @@ void job_continue (job_t *j, int cont)
if( !job_is_completed( j ) )
{
if( is_interactive && job_is_external( j ) )
if( j->terminal )
{
/* Put the job into the foreground. */
@@ -937,6 +921,7 @@ void job_continue (job_t *j, int cont)
{
int quit = 0;
// debug( 1, L"wait loop" );
/*
Wait for job to report. Looks a bit ugly because it has to
handle the possibility that a signal is dispatched while
@@ -953,7 +938,7 @@ void job_continue (job_t *j, int cont)
if( !quit )
{
debug( 3, L"select_try()" );
// debug( 1, L"select_try()" );
switch( select_try(j) )
{
case 1:
@@ -973,6 +958,7 @@ void job_continue (job_t *j, int cont)
short-lived jobs.
*/
int status;
// debug( 1, L"waitpid" );
pid_t pid = waitpid(-1, &status, WUNTRACED );
if( pid > 0 )
handle_child_status( pid, status );
@@ -1010,7 +996,7 @@ void job_continue (job_t *j, int cont)
/*
Put the shell back in the foreground.
*/
if( is_interactive && job_is_external( j ) )
if( j->terminal )
{
signal_block();
if( tcsetpgrp (0, getpid()) )