mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Readd the terminal flag for jobs, as not all jobs under job control should be given the terminal.
darcs-hash:20060201122715-ac50b-7efc499e8905e9898c214816d0a3468e077c7005.gz
This commit is contained in:
parent
7a1a5a6f01
commit
e95effb043
5 changed files with 47 additions and 32 deletions
4
common.h
4
common.h
|
@ -177,8 +177,8 @@ int my_wcswidth( const wchar_t *c );
|
|||
|
||||
/**
|
||||
This functions returns the end of the quoted substring beginning at
|
||||
\c in. It can handle both single and double quotes. Returns 0 on
|
||||
error.
|
||||
\c in. The type of quoting character is detemrined by examining \c
|
||||
in. Returns 0 on error.
|
||||
|
||||
\param in the position of the opening quote
|
||||
*/
|
||||
|
|
39
exec.c
39
exec.c
|
@ -409,13 +409,13 @@ static int setup_child_process( job_t *j, process_t *p )
|
|||
/* Wait till shell puts os in our own group */
|
||||
while( getpgrp() != j->pgid )
|
||||
sleep(0);
|
||||
|
||||
/* Wait till shell gives us stdin */
|
||||
if ( j->fg )
|
||||
{
|
||||
while( tcgetpgrp( 0 ) != j->pgid )
|
||||
sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait till shell gives us stdin */
|
||||
if ( j->terminal && j->fg )
|
||||
{
|
||||
while( tcgetpgrp( 0 ) != j->pgid )
|
||||
sleep(0);
|
||||
}
|
||||
|
||||
res = handle_child_io( j->io, (p==0) );
|
||||
|
@ -624,23 +624,24 @@ static int handle_new_child( job_t *j, process_t *p )
|
|||
wperror( L"setpgid" );
|
||||
}
|
||||
}
|
||||
|
||||
if( j->fg )
|
||||
{
|
||||
if( tcsetpgrp (0, j->pgid) )
|
||||
{
|
||||
debug( 1, _( L"Could not send job %d ('%ls') to foreground" ),
|
||||
j->job_id,
|
||||
j->command );
|
||||
wperror( L"tcsetpgrp" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j->pgid = getpid();
|
||||
}
|
||||
|
||||
if( j->terminal && j->fg )
|
||||
{
|
||||
if( tcsetpgrp (0, j->pgid) )
|
||||
{
|
||||
debug( 1, _( L"Could not send job %d ('%ls') to foreground" ),
|
||||
j->job_id,
|
||||
j->command );
|
||||
wperror( L"tcsetpgrp" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
7
parser.c
7
parser.c
|
@ -2179,13 +2179,12 @@ static void eval_job( tokenizer *tok )
|
|||
case TOK_STRING:
|
||||
{
|
||||
j = job_create();
|
||||
j->command=0;
|
||||
j->fg=1;
|
||||
j->constructed=0;
|
||||
j->terminal = j->job_control && (!is_subshell && !is_event);
|
||||
j->skip_notification = is_subshell || is_block || is_event || (!is_interactive);
|
||||
|
||||
|
||||
current_block->job = j;
|
||||
|
||||
|
||||
if( is_interactive )
|
||||
{
|
||||
if( tcgetattr (0, &j->tmodes) )
|
||||
|
|
26
proc.c
26
proc.c
|
@ -880,9 +880,8 @@ void job_continue (job_t *j, int cont)
|
|||
|
||||
if( !job_is_completed( j ) )
|
||||
{
|
||||
if( j->job_control && j->fg )
|
||||
if( j->terminal && j->fg )
|
||||
{
|
||||
|
||||
/* Put the job into the foreground. */
|
||||
signal_block();
|
||||
if( tcsetpgrp (0, j->pgid) )
|
||||
|
@ -916,15 +915,28 @@ void job_continue (job_t *j, int cont)
|
|||
if( cont )
|
||||
{
|
||||
process_t *p;
|
||||
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
p->stopped=0;
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
|
||||
if( j->job_control )
|
||||
{
|
||||
if (kill ( p->pid, SIGCONT) < 0)
|
||||
if( killpg( j->pgid, SIGCONT ) )
|
||||
{
|
||||
wperror (L"kill (SIGCONT)");
|
||||
wperror( L"killpg (SIGCONT)" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
{
|
||||
if (kill ( p->pid, SIGCONT) < 0)
|
||||
{
|
||||
wperror (L"kill (SIGCONT)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1007,7 +1019,7 @@ void job_continue (job_t *j, int cont)
|
|||
/*
|
||||
Put the shell back in the foreground.
|
||||
*/
|
||||
if( j->job_control && j->fg )
|
||||
if( j->terminal && j->fg )
|
||||
{
|
||||
signal_block();
|
||||
if( tcsetpgrp (0, getpid()) )
|
||||
|
|
3
proc.h
3
proc.h
|
@ -166,6 +166,9 @@ typedef struct job
|
|||
/** Whether the job is under job control */
|
||||
int job_control;
|
||||
|
||||
/** Whether the job wants to own the terminal when in the foreground */
|
||||
int terminal;
|
||||
|
||||
/** Pointer to the next job */
|
||||
struct job *next;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue