Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks for the fast reply, that list on the superuser post was interesting. – giodamelio Oct 27 '11 at 21:54

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)

share|improve this answer

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. It's man page says:

kill - send a signal to a process

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

The default signal for kill is TERM.

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.