Why Do I Get "Suspended (Tty Output)" in One Terminal But Not in Others

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

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.

How to resume a suspended (tty input) process [unix/mac]?

To add to the Chaitanya Bapats answer,

you can use jobs command to list the suspended jobs. The output will be something like this if you have more than one suspended jobs.

[1]  - suspended  sleep 400
[2] + suspended sleep 300

You can bring the job to foreground by using fg. If you have more than one suspended jobs, then you can use fg %ID. ID is the value inside [] in the output of jobs command.

Also, if you want to resume the job without bringing it to the foreground, you can use kill -CONT command. Example usage:

kill -CONT JOBID

You can also use bg command to move job to background. bg will resume the last suspended job. Also, bg %ID will resume the job with [ID] in jobs command output

How does launching `less` differ from launching `cat` in ZSH with regards to the usage of alternate screen and background suspension

(you don't specify your OS, but this answer is based on linux)

Using strace you can see stty doing an ioctl on fd 0 (stdin) toggling one bit in the c_lflag value of the termios struct.

strace also reveals that less will open /dev/tty and issue an ioctl on it to change the c_lflag.

So less simply does the same thing as stty tostop before outputting anything.



Related Topics



Leave a reply



Submit