Disabling Job Control in Bash (CTRL-Z)

bashbashrcjob-control

It happens to me sometimes, that I press CTRL+Z by accident and my application disappears into background. I know, I can bring it back with fg, so it's not such a big deal. But I am wondering about turning this job control off anyway. In my whole life, I cannot remember one instance when I needed it, it just looks to me as a relic form the past.

Is this OK to disable job control entirely? Or am I missing something, and this feature can be useful?
How would I disable it in my .bashrc

UPDATE:

I have tried set +m as suggested by @Falsenames. However, this only works when I type it in the terminal. Adding set +m into my .bashrc has no effect.

Best Answer

You can add the following into your command line to stop using monitoring mode.

set +m

If you really need the ctrl-z functionality later, you can just type 'set -m' to enable monitoring for that session.

From man bash. Note that this is for '-m', with "+m" toggling that setting to disable.

set [+abefhkmnptuvxBCEHPT] [+o option] [arg ...] 
....
-m
    Monitor mode. Job control is enabled. This option is on by default for interactive
    shells on systems that support it (see JOB CONTROL above). Background processes 
    run in a separate process group and a line containing their exit status is printed
    upon their completion. 

As a last ditch effort, you may want to manually compile a version of bash without the "--enable-job-control" flag. Here is a quick install guide from GNU. If you do choose to go this route, DO NOT replace /bin/bash just in case background processes run through bash expect job control. Instead, make a /bin/bash.alt or another file. Your default shell can be changed to this alternate one by running usermod or editing /etc/passwd as root.

Related Question