Previous Table of Contents Next


Module 129
suspend (csh, ksh)

DESCRIPTION

The internal suspend command is actually a keystroke and a command. The default keystroke is Ctrl-Z. The Ctrl-Z suspends the current process. The process is placed in a suspended state and interactive control returns to the parent shell. For instance, assume you start a long process, such as cd /; 1s -1R > /tmp/ls.out, and forget to place the command in background. You can suspend it and then place it in background for further processing.

The Ctrl-Z is used to suspend any type of process that handles the suspend signal. It can be typed at any time. If the current process traps the suspend signal, the Ctrl-Z is processed and the job is suspended.

The suspend command can only be used while you are at a shell prompt. It is used to suspend a background job.

COMMAND FORMAT

Following is the general format of the suspend command.

     suspend
     Ctrl-Z

RELATED COMMANDS

Refer to the bg, fg, jobs, kill, and stop commands described in modules 9, 51, 68, 70, and 125.

APPLICATIONS

The suspend command provides a way to switch between multiple shells. You might have a login shell, a subshell in a different directory, and a su shell running simultaneously. To change between the three shells you can use the suspend command. You may need to use the jobs command. You must use the fg %job or bg job command to restart a suspended shell or process.

The Ctrl-Z key is useful when you are controlling processes within the same shell. You can toggle between vi and your shell using the Ctrl-Z key.

TYPICAL OPERATION

In this activity you use the suspend command to switch between two different shells. Begin at the shell prompt.

1.  Type PS1=memo-$PS1 ksh and press Return. A new shell is spawned with a prompt of memo-oldprompt>.
2.  Type suspend and press Return to suspend execution of the new subshell and return to your parent shell.
     cj> suspend
     [1] + Stopped (signal)   PS1=memo-$PS1 ksh
3.  Type jobs to display the suspended shell.
     cj> jobs
     [1] + Stopped (signal)    PS1=memo-$PS1 ksh
4.  Type fg %1 to bring the suspended shell into the foreground. You can now interact with the subshell.
5.  Type Ctrl-D to exit the subshell.
6.  Turn to Module 125 to continue the learning sequence.


Previous Table of Contents Next