Background Jobs and I/O

Jobs being executed in the background will stop if they attempt to read input from your terminal. If you tried to interactively remove $PUBDIR/junk in the background, this is what would happen:

					$ rm —i $PUBDIR/junk &
					[2]  +Stopped (tty input) rm —i $PUBDIR/junk &
				

The job is stopped because it needs to prompt you for input. The rm –i job is brought back into the foreground with the fg command and its prompt is displayed:

					$ fg %2
					rm —i $PUBDIR/junk
					rm: remove /usr/spool/uucppublic/junk? y
				

By default, jobs send their output to your terminal, even while running in the background. Here, the find command sends its output to the terminal, even though it is running in the background:

					$ find / —name core —print &
					[2] 1453 ...

Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The 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.