The difference between Linux background process management and ctrl+z (hang), CTRL + C (break), ctrl+\ (exit), and Ctrl+d (EOF) __linux

Source: Internet
Author: User
Tags clear screen terminates

Turn from: http://blog.csdn.net/fengyifei11228/article/details/5737371

http://idas643.blog.163.com/blog/static/167104838201341493846584/


First, the background process Management command

FG, BG, Jobs, &, CTRL + Z, CTRL + C, CTRL + \, CTRL + D
1, &
At the end of a command, you can put this command in the background, such as GFTP,
2, CTRL + Z
A command that is executing in the foreground can be placed in the background and paused and not executed
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 deletes the process identity of the task from the list known to the current shell environment; , the jobs command displays the background running or suspended task information in the current shell environment;
4. FG
Move commands in the background to the foreground to continue running
If you have more than one command in the background, you can use FG%jobnumber to call out the selected command,%jobnumber is the serial number (not PID) of the command in the background that was checked by the jobs command.
5, BG
A command paused in the background becomes a continuation (performed in the background)
If there are multiple commands in the background, you can use the BG%jobnumber will be selected commands,%jobnumber is through the jobs command to check the background is executing the order number (not PID)
To move a task to a background run:
CTRL + Z, then BG, so that the process is moved to the background, and the terminal can continue to accept the command.
Concept: Current Tasks
If the background task number has 2, [1],[2]; If the first background task is executed successfully and the second background task is still in progress, the current task automatically becomes the background task of the background task number "[2]". So you can draw the point that the current task is going to change. When a user enters commands such as FG, BG, and stop, the current task is changed if no quotes are added.

II. termination of the process
End of background process:
Method One:
View the job number (assuming num) through the jobs command, and then execute the kill%num
Method Two:
View the job's process number (PID, assumed PID) through the PS command, and then execute kill PID
Termination of foreground process:
CTRL + C

Iii. suspension of the process (meaning of the pause)
Hangs of background process:
Execute with the Stop command in Solaris, view the job number (assuming num) through the jobs command, and then execute the Stop%num;
In Redhat, no stop command exists, and the process can be suspended by executing the command kill-stop PID;
When you want to rerun the currently suspended task, the status of the pending job can be changed from stopped to running by BG%num, and it is still in the background, and the command FG%num can be executed when the need changes to the foreground.
Hangs of the foreground process:
Ctrl+z;


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


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

1, four kinds of operation performance

CTRL + C forcibly interrupts execution of the current program.
Ctrl+z interrupted the task, but the task did not end, he was still in the process, just put it in the background and maintained a pending state. If you want it to continue running in the background, you need the BG process number to keep it running, and then use the FG process number to foreground the background process.

Ctrl+\ says Exit.

Ctrl+d indicates that the current input is terminated (that is, the user is no longer issuing instructions to the current program), then Linux usually ends the current program.

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

Linux under:
Ctrl-c sends SIGINT signals to all processes in the foreground process group. Often used to terminate a running program.
Ctrl-z sends SIGTSTP signals to all processes in the foreground process group, often used to suspend a process.
Instead of sending a signal, ctrl-d represents a special binary value that represents EOF.
Ctrl-\ sends sigquit signals to all processes in the foreground process group, terminating the foreground process and generating core files.

Key Function
Ctrl-c Kill Foreground process
Ctrl-z Suspend Foreground process
ctrl-d Terminate input, or exit shell
Ctrl-s Suspend Output
Ctrl-q Resume Output
Ctrl-o Discard Output
Ctrl-l Clear Screen

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.