Search code examples
linuxbashterminalcommand-linejobs

How to bring a job to foreground and then disable job control in bash?


I have a program running in a terminal window. I wish to disable the Ctrl+Z shortcut from suspending the process.

After pressing Ctrl+Z, the command fg && set +m unfortunately disables job control only after the process has finished. I could use set +m before I start the process but my questions is about the situation where I have already started the process and I need to disable job control.


Solution

  • I asked this question at Super User, as suggested, and received a detailed answer.

    What worked for me was running tty after using Ctrl+Z to find out the terminal name, /dev/pts/0 in this case, and then running </dev/pts/0 stty susp '' from another terminal. This does not disable job control but disables the terminal driver from sending SIGTSTP upon Ctrl+Z.