stop a process?

I have started servers and thought I stopped them with ctrl c, but they are continuing.

2 Replies

Sometimes it can take a moment to stop a process with ctrl+c as it allows the process to shut itself down gracefully.

If you want to end a process quicker than that, you can use the kill -9 command to stop it instantly. There's more info on killing processes in Linux here:

https://www.linux.com/topic/desktop/how-kill-process-command-line/

And, there's a bit more info on the difference between kill or ctrl+c and kill -9 here:

https://major.io/2010/03/18/sigterm-vs-sigkill/

@swarr22 --

As I understand it from our previous conversations, your servers are running under node (and hopefully in the background).

There are certain signals that a process cannot catch…SIGKILL (9) is one of these. There are several others. Most well-behaved programs designed to run in the background catch SIGHUP (1 -- hangup…a relic from the days when Unix used RS-232 terminals). Most well-behaved programs designed to run in the foreground catch SIGINT (2 -- interrupt…a Ctl-C received from the keyboard).

If you have a man page for node, it will tell you which signals it catches. My guess is that it catches SIGHUP so that you can terminate a node server process with

kill -1 pid

or

kill -HUP pid

where pid is the process id of the process you want to receive the signal.

You can find an overview on your system about signals by typing

man 7 signal

or reading here:

https://www.computerhope.com/unix/signals.htm

FWIW, sending SIGKILL to a process should be your last resort…especially if the process maintains internal state that may be required to restart the process. SIGKILL is murder…with no chance given to the process to stop with even minimal grace.

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct