Other Applications of Job Control
This section describes other ways in which job control is useful.
Controlling Background Job Output
Putting a command in the background is handy when you want to do other things while the job is running, but the command may write output to the terminal at inconvenient times. If you are editing a file or composing a mail message, you may not want a background job to splatter output all over the screen. Or, if you have multiple background jobs, their output streams may interfere with each other. To avoid these problems, you can use the following command to force background jobs to stop when they are ready to write to the terminal:
% stty tostop
When you're ready to see the output of a background job that is stopped waiting to write, bring the job to the foreground.
To let background jobs write to the terminal at any time, use the following command:
% stty -tostop
The following command sequence illustrates the difference between stty tostop and stty âtostop:
%stty tostop
Turn tostop on %date &
Run command in the background [1] 24980 Shell reports the job number and the process ID [1] + Suspended (tty output) date Job stops when ready to produce output %fg
Bring the job to the foreground date Shell echoes command line Mon Sep 12 11:59:14 CDT 1994 Job writes output %stty -tostop
Turn tostop off %date &
Run the command in the background [1] 24982 Shell prints the job number and the process ID Mon Sep 12 11:59:21 CDT 1994 Job writes output without stopping ...
Get Using csh & tcsh now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.