@@ -4274,7 +4274,27 @@ notify_of_job_status ()
4274
4274
if (startup_state == 0 && WIFSIGNALED (s ) == 0 &&
4275
4275
((DEADJOB (job ) && IS_FOREGROUND (job ) == 0 ) || STOPPED (job )))
4276
4276
continue ;
4277
-
4277
+
4278
+ /* Do the same thing and don't print anything or mark as notified
4279
+ for the signals we're not going to report on. This is the opposite
4280
+ of the first two cases under case JDEAD below. */
4281
+ else if (interactive_shell == 0 && DEADJOB (job ) && IS_FOREGROUND (job ) == 0 &&
4282
+ WIFSIGNALED (s ) && (termsig == SIGINT
4283
+ #if defined (DONT_REPORT_SIGTERM )
4284
+ || termsig == SIGTERM
4285
+ #endif
4286
+ #if defined (DONT_REPORT_SIGPIPE )
4287
+ || termsig == SIGPIPE
4288
+ #endif
4289
+ || signal_is_trapped (termsig )))
4290
+ continue ;
4291
+
4292
+ /* hang onto the status if the shell is running -c command */
4293
+ else if (startup_state == 2 && subshell_environment == 0 &&
4294
+ WIFSIGNALED (s ) == 0 &&
4295
+ ((DEADJOB (job ) && IS_FOREGROUND (job ) == 0 ) || STOPPED (job )))
4296
+ continue ;
4297
+
4278
4298
/* If job control is disabled, don't print the status messages.
4279
4299
Mark dead jobs as notified so that they get cleaned up. If
4280
4300
startup_state == 2 and subshell_environment has the
@@ -4297,7 +4317,7 @@ notify_of_job_status ()
4297
4317
4298
4318
/* Print info on jobs that are running in the background,
4299
4319
and on foreground jobs that were killed by anything
4300
- except SIGINT (and possibly SIGPIPE). */
4320
+ except SIGINT (and possibly SIGTERM and SIGPIPE). */
4301
4321
switch (JOBSTATE (job ))
4302
4322
{
4303
4323
case JDEAD :
@@ -4317,6 +4337,7 @@ notify_of_job_status ()
4317
4337
}
4318
4338
else if (IS_FOREGROUND (job ))
4319
4339
{
4340
+ /* foreground jobs, interactive and non-interactive shells */
4320
4341
#if !defined (DONT_REPORT_SIGPIPE )
4321
4342
if (termsig && WIFSIGNALED (s ) && termsig != SIGINT )
4322
4343
#else
@@ -4330,9 +4351,13 @@ notify_of_job_status ()
4330
4351
4331
4352
fprintf (stderr , "\n" );
4332
4353
}
4354
+ /* foreground jobs that exit cleanly */
4355
+ jobs [job ]-> flags |= J_NOTIFIED ;
4333
4356
}
4334
- else if (job_control ) /* XXX job control test added */
4357
+ else if (job_control )
4335
4358
{
4359
+ /* background jobs with job control, interactive and
4360
+ non-interactive shells */
4336
4361
if (dir == 0 )
4337
4362
dir = current_working_directory ();
4338
4363
pretty_print_job (job , JLIST_STANDARD , stderr );
@@ -4341,7 +4366,14 @@ notify_of_job_status ()
4341
4366
_ ("(wd now: %s)\n" ), polite_directory_format (dir ));
4342
4367
}
4343
4368
4344
- jobs [job ]-> flags |= J_NOTIFIED ;
4369
+ /* Interactive shells without job control enabled are handled
4370
+ above. */
4371
+ /* XXX - this is a catch-all in case we missed a state */
4372
+ else
4373
+ {
4374
+ internal_debug ("notify_of_job_status: catch-all setting J_NOTIFIED on job %d (%d), startup state = %d" , job , jobs [job ]-> flags , startup_state );
4375
+ jobs [job ]-> flags |= J_NOTIFIED ;
4376
+ }
4345
4377
break ;
4346
4378
4347
4379
case JSTOPPED :
0 commit comments