DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Controlling processes

Moving background jobs to the foreground

In order to terminate a background job using a keyboard interrupt sequence, you must first move it into the foreground. To do this, use the fg(C) command followed by a ``%'' sign, then the PID, the command name, or the job number. For example, to move the find background process to the foreground, type the following:

   $ jobs
   [2] +  Running                 tar tv3 * &
   [1] -  Running                 find / -name README -print > logfile &
   $ fg %find
   find / -name README -print > logfile
Note that the command line is returned, without the trailing ampersand. The following command line has the same effect:
   $ fg %2
   find / -name README -print > logfile
The process now executes in the foreground; that is, it takes control of the terminal, and will accept input typed at the keyboard, including interrupt sequences such as <Ctrl>Z.

fg entered without an argument, where only one background job exists, moves that job into the foreground. Where there are two or more background jobs, entering fg without an argument moves the job placed in the background most recently into the foreground.


Next topic: Moving foreground jobs to the background
Previous topic: Suspending a job

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003