Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell bash not to issue warnings "cannot set terminal process group" and "no job control in this shell" when it can't assert job control?

To create a new interactive bash shell I call bash -i. Due to issues with my environment, bash cannot assert job control (I'm using cygwin bash in GNU emacs) and issues warnings ("cannot set terminal process group" and "no job control in this shell"). - I have to live with the disabled job control in my environment, but I would like to get rid of the warning:

How can I tell bash not to assert job control and not to issue these warnings? I obviously still want the shell as an interactive one.

Note: I have tried set -m in .bashrc, but bash still writes out the warnings on start up - the ~/.bashrc file might be executed after the shell tries to assert job control. Is there a command line option which would work?

like image 965
halloleo Avatar asked Oct 07 '22 01:10

halloleo


1 Answers

man bash says about set options that The options can also be specified as arguments to an invocation of the shell. Note you will need +m not -m. Admittedly the manual isn't quite clear on that.

However looking at bash source code (version 4.2), apparently it ignores the state of this flag. I would say this is a bug.

Applying the following small patch makes bash honor the m flag on startup. Unfortunately this means you will have to recompile bash.

--- jobs.c.orig 2011-01-07 16:59:29.000000000 +0100
+++ jobs.c      2012-11-09 03:34:49.682918771 +0100
@@ -3611,7 +3611,7 @@
     }

   /* We can only have job control if we are interactive. */
-  if (interactive == 0)
+  if (interactive == 0 || !job_control)
     {
       job_control = 0;
       original_pgrp = NO_PID;

Tested on my linux machine where job control is available by default, so the error messages you see on mingw are not printed here. You can still see that bash honors the +m now, though.

$ ./bash --noprofile --norc
$ echo $-
himBH
$ fg
bash: fg: current: no such job
$ exit
$ ./bash --noprofile --norc +m
$ echo $-
hiBH
$ fg
bash: fg: no job control
like image 68
Jester Avatar answered Oct 10 '22 02:10

Jester