Ctrl+Z or What to do when Ctrl+C doesn’t work

Ctrl+Z or What to do when Ctrl+C doesn’t work

When a process launched become hanged, the most useful option to kill it is to press Ctrl+C, but what to do when Ctrl+C doesn’t work?
In this cases it is very useful to use Ctrl+Z. While Ctrl+C tries to kill the process with the signal SIGINT, Ctrl+Z sends the process to the background, releasing the terminal that was inoperative because the process, and giving us the control again.
Let’s see how to do it using an example. (At the end of the post you can find a video explaining all the process)

To simulate a hang process I am going to launch the python script ignoring_CtrlC.py, that intercept the Ctrl+C signal, making a forever process.

Executing ignoring_CtrlC.py

When I execute the script, and press Ctrl+C this is what happen

CtrlC doesnt work 01

Ctrl+C is not working, instead is displaying a message.

Let’s press now Ctrl+Z and see what happen now

CtrlC doesnt work 02

CtrlC doesnt work 03
The script is now stopped! but still alive at background, it is time to kill it!!

Killing a background process

To kill a background process, we use the command kill, but instead of use the PID of the process, we have to use the background ID, that is indicated between [].

CtrlC doesnt work 04

CtrlC doesnt work 05

Job done!!
The process is killed and the terminal control recovered 🙂

Video explaining all the process

Get CollectNode now !

Leave CollectNode to make the hard work, and spend your time where really matters.

Video: Understanding CollectNode output

Video: Understanding CollectNode output

In this video we can check the CollectNode output. How CollectNode executes a simple command, and gets the report, which is explained. The command to execute is:

The getent command displays entries from databases supported by the Name Service Switch libraries

We want to know if the account apache is available at the servers involved.

The hosts file used has 7 servers, one server is duplicated and other that doesn’t exist, in order to see the behaviour of CollectNode in these cases.

Understanding CollectNode output

Get CollectNode now !

Leave CollectNode to make the hard work, and spend your time where really matters.

video: How to get list of servers sorted by OS

video: How to get list of servers sorted by OS

In this video we will see how to get a list of servers sorted by OS, displaying the operating system for each one, CollectNode gets the servers from a file, then analyze them and finally displays the report.

Enjoy!

 

Get CollectNode now !

Leave CollectNode to make the hard work, and spend your time where really matters.

Pin It on Pinterest