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

36,769

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.

Share:
36,769

Related videos on Youtube

oliver
Author by

oliver

Updated on July 09, 2022

Comments

  • oliver
    oliver almost 2 years

    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.

  • xeruf
    xeruf over 5 years
    did not fix it for me unfortunately :c Trying to run multiple gradle builds in the background, but they are all suspended
  • Barmar
    Barmar over 5 years
    Could something in the build script be changing the stty settings? What does stty --all show?
  • xeruf
    xeruf over 5 years
    This: pastebin.com/nGzySBS2 I am sure that nothing changes the stty settings in the buildscripts. I use zsh btw. This is the command that starts each build: (gradle build --no-daemon --console=rich &>"/tmp/build-$(basename $d)") &
  • Barmar
    Barmar over 5 years
    Maybe zsh manages background processes differently from bash.