aboutsummaryrefslogtreecommitdiffhomepage
path: root/proc.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-01-31 03:54:26 +1000
committerGravatar axel <axel@liljencrantz.se>2006-01-31 03:54:26 +1000
commitf59e9baab9f71a1f345dfec20ff27f7bbd1b694b (patch)
treef5cc69c8c7b87cba92ccdd68c9778574546478b5 /proc.c
parent1c6f685522083550abaf1bd4ba2ab7f0f989de30 (diff)
Rename the 'terminal' flag to 'job_control', make sure fg and bg only considers jobs under job control and make it configurable which jobs are put under job control using the status builtin. Also add an option to the status builtin to print a stack trace.
darcs-hash:20060130175426-ac50b-46fb79797284cb600c67cb19462b53761446f00a.gz
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/proc.c b/proc.c
index ed20daf3..366a3b5c 100644
--- a/proc.c
+++ b/proc.c
@@ -83,6 +83,7 @@ int is_login=0;
int is_event=0;
int proc_had_barrier;
pid_t proc_last_bg_pid = 0;
+int job_control_mode = JOB_CONTROL_INTERACTIVE;
/**
The event variable used to send all process event
@@ -229,6 +230,10 @@ job_t *job_create()
res->next = first_job;
res->job_id = free_id;
first_job = res;
+
+ res->job_control = (job_control_mode==JOB_CONTROL_ALL) ||
+ ((job_control_mode == JOB_CONTROL_INTERACTIVE) && (is_interactive));
+
// if( res->job_id > 2 )
// fwprintf( stderr, L"Create job %d\n", res->job_id );
return res;
@@ -875,37 +880,34 @@ void job_continue (job_t *j, int cont)
if( !job_is_completed( j ) )
{
- if( j->terminal )
- {
-
+ if( j->job_control && j->fg )
+ {
+
/* Put the job into the foreground. */
- if( j->fg )
+ signal_block();
+ if( tcsetpgrp (0, j->pgid) )
{
- signal_block();
- 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;
+ }
+
+ if( cont )
+ {
+ if( tcsetattr (0, TCSADRAIN, &j->tmodes))
{
- debug( 1,
- _( L"Could not send job %d ('%ls') to foreground" ),
- j->job_id,
+ debug( 1,
+ _( L"Could not send job %d ('%ls') to foreground" ),
+ j->job_id,
j->command );
- wperror( L"tcsetpgrp" );
+ wperror( L"tcsetattr" );
return;
- }
-
- if( cont )
- {
- if( tcsetattr (0, TCSADRAIN, &j->tmodes))
- {
- debug( 1,
- _( L"Could not send job %d ('%ls') to foreground" ),
- j->job_id,
- j->command );
- wperror( L"tcsetattr" );
- return;
- }
- }
- signal_unblock();
+ }
}
+ signal_unblock();
}
/*
@@ -1005,7 +1007,7 @@ void job_continue (job_t *j, int cont)
/*
Put the shell back in the foreground.
*/
- if( j->terminal )
+ if( j->job_control && j->fg )
{
signal_block();
if( tcsetpgrp (0, getpid()) )