home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 12.6 Notification When Jobs Change State Chapter 12
Job Control
Next: 12.8 Job Control in a Nutshell
 

12.7 Stop Background Output with stty tostop

If you put a job in the background ( 1.26 ) and don't redirect ( 13.1 ) its output, text that the job writes to its standard output and standard error will come to your screen. Those messages can mess up the screen while you're using another program. You could lose the (maybe important) messages, too - they might scroll off your screen and be lost, or your foreground program may clear the screen and erase them.

Most BSD UNIX systems, and a lot of newer UNIXes with job control, have the command stty tostop . Type that command at a prompt, or put it in your .login or .profile file ( 2.1 ) .* [2] After that, your shell's background jobs that try to write to your terminal will be stopped. When you want to see the background job's output, bring it into the foreground (with fg ).

[2] *This command sets the UNIX terminal device driver ( 42.1 ) for all processes started on it. You don't need to set this for subshells ( 2.2 ) .

How will you know that the background job has been stopped? The shell will print a message like this just before it prints a prompt:

[1] + Stopped (tty output)    

somejob


%

The shell can also interrupt your foreground job with that message as soon as the background job is stopped. To make it do that, set notify ( 12.6 ) .

You can turn off this feature and let background jobs write to your terminal any time with the command:

% 

stty -tostop

Article 41.2 has more about stty .

- JP


Previous: 12.6 Notification When Jobs Change State UNIX Power Tools Next: 12.8 Job Control in a Nutshell
12.6 Notification When Jobs Change State Book Index 12.8 Job Control in a Nutshell

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru