Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to end the process under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to end the process under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Have you ever encountered that when you use the application, it suddenly becomes unresponsive and crashes unexpectedly. When you try to start the application again, but there is no response, this is because the original application process will not be completely closed, so you cannot start the application again, so how to solve this situation? however, our general solution is to terminate the application process.

Use the command line or character terminal interface Ctrl + C

One problem with invoking the gedit program from the command line (if you don't use the gedit & command) is that the shell session is blocked and cannot release the command line prompt. In this case, Ctrl + C (the key combination of Ctrl and C) works well. This will terminate the gedit and all work will be lost (unless the file has been saved). Ctrl + C sends a SITING signal to gedit. This is a stop signal that terminates the process by default, which instructs shell to stop running gedit and return to the loop of the main function, and you will return to the prompt.

$gedit ^ CCtrl + Z

It is called a pending character. It sends SIGTSTP signals to the process. It is also a stop signal, but the default behavior is not to kill the process, but to suspend the process.

The following command will stop (kill / interrupt) gedit and return to the shell prompt.

$gedit ^ Z [1] + Stopped gedit$

Once the process is suspended (in the case of gedit), nothing can be written or done in gedit. In the background, the process becomes a job that can be verified using the jsbs command.

$jobs [1] + Stopped gedit

Jobs allows you to control multiple processes in a single shell session. You can terminate, resume the job, or move the job to the foreground or background as needed.

Let's restore gedit in the background and release the prompt to run other commands. You can do this with the bg command, followed by the job ID (note the [1] shown by the jobs command above, which is the job ID).

$bg 1 [1] + gedit &

This is similar to using gedit directly to start the program:

$gedit & using kill

The kill command provides precise control of the signal, allowing you to send a signal for the process by specifying the signal name or signal number, followed by the process ID or PID.

One thing I like about the kill command is that it can also control the process according to the job ID. Let's use the gedit & command to start the gedit service in the background. Suppose I get a job ID for gedit through the jobs command, let's send a SIGINT signal for gedit:

$kill-s SIGINT 1

The job ID needs to be prefixed with%, otherwise kill will treat it as PID.

Without explicitly specifying the signal, the kill still works. At this point, a SIGTERM signal that interrupts the process is sent by default. Execute kill-l to view a list of signal names and use the man kill command to read the manual.

Use killall

If you don't want to use a specific working ID or PID,killall, you can use a specific process name. The easiest way to use killall to interrupt gedit is:

$killall gedit

It terminates all processes named gedit. Similar to kill, the default signal sent is SIGTERM. Use the-I option to ignore the case of the process name.

$gedit & [1] 14852$ killall-I GEDIT [1] + Terminated gedit

Check the manual to learn more killall command options (such as-u).

Use xkill

Have you ever encountered a player crash, such as VLC [2] gray screen or hang? Now you can get the PID of the process as above to kill it, or use the xkill command to terminate the application.

How to end a process in Linux how to end a process in Linux

Using xkill

Xkill allows you to close the window using the mouse. Just execute the xkill command on the terminal, and it will change the mouse cursor to an X or a small skeleton icon. Click x on the process window you want to close. Use xkill carefully, as described in the manual is consistent, it is dangerous. I already warned you!

Thank you for reading this article carefully. I hope the article "how to end the process under Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report