Showing posts with label process. Show all posts
Showing posts with label process. Show all posts

Thursday, March 28, 2013

Unix Move a process to background and bring it back to foreground

It is possible to be move a process to background so that we have the prompt back for other activities and bring the process that was send background to foreground.



Use CTRL+z to suspends a process (SIGTSTP)

(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)# cp -rp lastlog lastlog.old
^Z
[1]+  Stopped                 cp -rp lastlog lastlog.old
(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)#

Use bg command to send the command to background 

(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)# bg
[1]+ cp -rp lastlog lastlog.old &
(MySolaris10:/var/adm)#

Once command completes, it returns the status of the pid

(MySolaris10:/var/adm)#
[1]+  Done                    cp -rp lastlog lastlog.old
(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)#

Using fg will bring the process to foreground.