Linux background Process Management and the difference between CTRL + Z (hang), CTRL + C (interrupt), ctrl+\ (exit), and Ctrl+d (EOF) (RPM)

Source: Internet
Author: User
Tags sigint signal terminates

First, the background process Management command

FG, BG, Jobs, &, CTRL + Z, CTRL + C, CTRL + \, CTRL + D
1. &
Add to the end of a command, you can put this command in the background to perform, such as Firefox &

2, CTRL + Z
You can put a command that is being executed in the foreground in the background and is paused, not executable


3. Jobs
See how many commands are currently running in the background
The JOBS-L option shows that the pid,jobs status of all tasks can be running, stopped, Terminated, but if the task is terminated (kill), the shell removes the process identity of the task from the list known to the current shell environment; , the Jobs command displays the task information that is running in the background or suspended in the current shell environment;
4, FG
Move commands in the background to the foreground to continue running
If there are multiple commands in the background, you can use FG%jobnumber to bring up the selected command,%jobnumber is the ordinal (not PID) of the command being executed in the background through the jobs command.


5. BG
A command paused in the background to continue execution (performed in the background)
If there are multiple commands in the background, you can use BG%jobnumber to bring up the selected command,%jobnumber is the ordinal (not PID) of the command being executed in the background through the jobs command.
To move a task to the background run:
First CTRL + Z, then BG, so that the process is moved to the background to run, the terminal can continue to accept commands.


Concept: Current task
If there are 2 task numbers in the background, [1],[2]; If the first background task executes successfully and the second background task is still in progress, the current task will automatically become a background task for the background task number "[2]". So it can be concluded that the current task is subject to change. When the user enters commands such as FG, BG, and stop, the current task is changed if no quotation marks are added

II. termination of the process
Termination of the background process:
Method One:
View the job number (assuming num) through the jobs command, and then execute the kill%num


Method Two:
Use the PS command to view the job's process number (PID, assuming PID), and then execute the kill PID


Termination of the foreground process:
CTRL + C
Third, the process hangs (the meaning of the pause)
Hang of background process:
Execute through the Stop command in Solaris, view the job number (assuming num) through the jobs command, and then execute the Stop%num;
In Redhat, the Stop command does not exist, and the process can be suspended by executing the command kill-stop PID;
When you want to re-execute the currently suspended task, the status of the suspended job can be changed from stopped to running through BG%num, and the command FG%num can be executed when it needs to be executed in the foreground instead;
Foreground process hangs:
CTRL + Z;

Iv. Other effects of Kill
In addition to terminating the process, kill can also send other signals to the process, using kill-l to see the signals that kill supports.
Sigterm is the signal that kill sends without parameters, meaning that the process terminates, but execution depends on whether the process supports it. If the process has not been terminated, you can use the Kill-sigkill PID, which is the kernel to terminate the process and the process cannot listen for this signal.

The difference between CTRL + Z (hang), CTRL + C (interrupt), ctrl+\ (exit), and Ctrl+d (EOF)

1. The performance of four kinds of operation

CTRL + C forcibly interrupts the execution of the current program.
CTRL + Z will abort the task, but this task is not finished, he is still in the process, just put in the background and maintain a suspended state. If you want it to continue running in the background, use the BG process number to keep it running, and the FG process number to foreground the background process.

Ctrl+\ indicates exit.

Ctrl+d indicates the end of the current input (that is, the user no longer issues instructions to the current program), then Linux will usually end the current program.

2, ctrl+c,ctrl+d,ctrl+z in the meaning of Linux.

Under Linux:
Ctrl-c sends a SIGINT signal to all processes in the foreground process group. is often used to terminate a running program.
Ctrl-z sends a SIGTSTP signal to all processes in the foreground process group, which is often used to suspend a process.
Instead of sending a signal, ctrl-d represents a special binary value that represents EOF.
Ctrl-\ sends a sigquit signal to all processes in the foreground process group, terminates the foreground process, and generates a core file.

Reprint Address: 39722583

Linux background Process Management and the difference between CTRL + Z (hang), CTRL + C (interrupt), ctrl+\ (exit), and Ctrl+d (EOF) (RPM)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.