4

When I shutdown my minecraft it never closes all the way, I have looked for a solution but found none. After awhile I gave up and decided that I would manually kill it when I wanted to close it.

If I use pgrep then kill in the terminal it seems to have no affect, but when I open the system monitor and right click and kill it, it shuts down nicely.

What are the differences between the System Monitor way and the Terminal way? Does the System Monitor do something else in the background that the kill command does not?

3 Answers 3

5

There is no difference between the kill command and the System Monitor's 'kill'. The System Monitor just gives some arguments to kill that I assume you don't know.

When you kill <process-number>, it's actually sending a signal to that process to cleanly exit. This is called a SIGTERM. In order to kill a process unconditionally, potentially causing data loss, you need to send a different signal:

kill -9 <process-number>

This sends a SIGKILL to the process, which immediately ends its execution. System Monitor uses kill -9 when you ask to 'kill' a process rather than simply 'close' it.

This answer on the SuperUser Stack Exchange should be of help.

1
  • Thanks for the fast reply, that list on the superuser post was interesting.
    – giodamelio
    Oct 27, 2011 at 21:54
1

WHen killing an application using the terminal, I guess you ran:

kill 1234

On the System Monitor, you selected the process and chose for sending KILL to the process.

By default, the signal that's sent to the process when using plain kill $pid is TERM. This allows applications to terminate gracefully. However, when sending KILL, the program is immediately gone without a chance to shut down cleanly (i.e. saving data). To send a KILL signal from the command line, use:

kill -KILL 1234

(the alternate way to run this command is kill -9 1234, this is just a matter of preference)

0

That is because by default your pgrep kill sends a SIGTERM (terminate). If the application is not in a good state then a SIGTERM won't work. The "Kill Process" in System Monitor sends the SIGKILL command which will literally kill it. They are two different signals being sent. If you want to do it with pgrep you would use the kill -9, the -9 option sends the SIGKILL signal and will then be exactly the same as what System Monitor's "Kill Process" does.

FYI, the name of the kill command is a bit misleading. man kill says:

kill - send a signal to a process

This could be any signal. To see a list of all signals type man --sections=7 signal and scroll down.

Then says:

The default signal for kill is TERM.

See https://askubuntu.com/a/716814/11929 for more info.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .