Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  26] [ 0]  / answers: 1 / hits: 47419  / 2 Years ago, tue, april 12, 2022, 11:33:25

I know there is ctrl+c, but sometimes that doesn't work. In Ubuntu desktop I can just close the terminal window and open a new one when this happens, but how would this be solved using the CLI in Ubuntu server (without restarting the box)?


More From » server

 Answers
6

CTRL+C will send SIGINT to the application. The application can configure a handler for this signal or it can ignore the signal. By default there is no handler and SIGINT will kill the application.


You can use CTRL+ which will send SIGQUIT. This will also generate a core dump if the core limit is not zero.


You can suspend the process and return to shell with CTRL+Z, this will stop the execution of the process and return to the shell prompt. The process will be in memory and it will be available as a job in the current shell. You can then use kill -SIGNAL %% or kill -SIGNAL %<job_ID> to send a signal to that job. E.g. to kill the last job use kill -9 %%


If none of them are working you can always send SIGTERM, then, as last resort, SIGKILL which will terminate any process. This signal as any other signals must be sent as the same user as the process you are trying to stop or as root. To send SIGKILL to process, first find the process with ps aux or ps -edf, then run kill -SIGKILL <process_ID>, where the <process_ID> is the PID column in ps output.


The signals can not be delivered if the process is in an uninterruptible call. Uninterruptible calls are kernel functions that can not be stopped and usually happen because of a bad driver (e.g. a driver that is not reentrant). A process that is in uninterruptible sleep can not be stopped until the call gets completed or the server is rebooted. Those signals will be held in the pending (Pnd) signals list. The pending signals for a process can be show with this small script that is just geting them from /proc/<PID>/status.


If a process becomes a zombie, it will not use any resources only taking space in the process table. A zombie process can not receive signals.


The list of signals for the current architecture can be found with kill -l


See the man pages of kill, ps and bash. To see a man page use something like: man ps


[#41715] Wednesday, April 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
weamp

Total Points: 197
Total Questions: 115
Total Answers: 92

Location: Mauritania
Member since Sun, May 7, 2023
1 Year ago
;