why do I get "Suspended (tty output)" in one terminal but not in others?

oliver picture oliver · Jun 5, 2014 · Viewed 27.2k times · Source

Apparently I've done something strange/wrong in a tcsh shell, and now whenever I start an application in the background which prints to stdout the application is suspended (stopped). Weird thing is, this behavior only happens in this terminal; if I do the same in another terminal, the application just keeps running in the background and prints it output to the terminal.

In the "broken" terminal I have to put the suspended application back into foreground (with fg) to have it continue.

Example:

thehost:/tmp/test1(277)> ls -l &
[3] 1454
thehost:/tmp/test1(278)> 
[3]  + Suspended (tty output)        ls --color=auto -l
thehost:/tmp/test1(278)> fg
ls --color=auto -l
total 0
thehost:/tmp/test1(279)> 

Same command executed in another terminal works fine:

thehost:/tmp/test1(8)> ls -l &                                                 
[1] 2280                                                                        
thehost:/tmp/test1(9)> total 0                                                 

[1]    Done                          ls --color=auto -l                         
thehost:/tmp/test1(9)>                                                         

Starting a bash in the affected terminal doesn't solve this either:

thehost:/tmp/test1(280)> bash
oliver@thehost:/tmp/test1$ ls -l &
[1] 2263
oliver@thehost:/tmp/test1$ 

[1]+  Stopped                 ls --color=auto -l
oliver@thehost:/tmp/test1$ fg
ls --color=auto -l
total 0
oliver@thehost:/tmp/test1$ 

Getting a new login shell (with su - oliver) doesn't solve this either.

So: what did I do in this terminal to get this behavior, and what can I do to get back the normal behavior? It's not really an important problem (I could close the terminal and open a new one), but I'm curious :-)

Happens on Linux RHEL 6.4 64bit, with KDE 4.11.5 and Konsole 2.11.3, and tcsh 6.17.00.

Answer

Barmar picture Barmar · Jun 5, 2014

This will fix it:

stty -tostop

From the man page:

tostop (-tostop)

Send (do not send) SIGTTOU for background output. This causes background jobs to stop if they attempt terminal output.

This tostop is normally the default setting, as it's usually undesirable to mix the output of multiple jobs. So most people just want the foreground job to be able to print to the terminal.