Free Hosting Online for WorkStations

< Previous | Contents | Next >

Stopping (Pausing) A Process

Sometimes we'll want to stop a process without terminating it. This is often done to allow a foreground process to be moved to the background. To stop a foreground process, press Ctrl-z. Let's try it. At the command prompt, type xlogo, the Enter key, then Ctrl- z:



[me@linuxbox ~]$ xlogo

[1]+ Stopped [me@linuxbox ~]$

xlogo

[me@linuxbox ~]$ xlogo

[1]+ Stopped [me@linuxbox ~]$


After stopping xlogo, we can verify that the program has stopped by attempting to re- size the xlogo window. We will see that it appears quite dead. We can either restore the program to the foreground, using the fg command, or move the program to the back- ground with the bg command:


[me@linuxbox ~]$ bg %1 [1]+ xlogo & [me@linuxbox ~]$

[me@linuxbox ~]$ bg %1 [1]+ xlogo & [me@linuxbox ~]$


As with the fg command, the jobspec is optional if there is only one job.

Moving a process from the foreground to the background is handy if we launch a graphi- cal program from the command, but forget to place it in the background by appending the trailing “&”.

Why would we want to launch a graphical program from the command line? There are two reasons. First, the program you wish to run might not be listed on the window man- ager's menus (such as xlogo). Secondly, by launching a program from the command line, you might be able to see error messages that would otherwise be invisible if the pro- gram were launched graphically. Sometimes, a program will fail to start up when launched from the graphical menu. By launching it from the command line instead, we may see an error message that will reveal the problem. Also, some graphical programs have many interesting and useful command line options.


Top OS Cloud Computing at OnWorks: