Linux – does Firefox refuse to die despite killing it with pkill -9

commandcommand linelinuxprocess

I am issuing the following command to kill Firefox on my Red Hat Linux box:

[subhrcho@slc04lyo ~]$ pkill -9 -f firefox
[subhrcho@slc04lyo ~]$ 

However, when I try to invoke Firefox through Applications -> Internet -> Firefox, it says:

Firefox is already running, but is not responding. To open a new
window, you must first close the existing Firefox process, or restart
your system.

Best Answer

Do not use kill -9 if not absolutely necessary, and most of the time it is not absolutely necessary. Always try kill (without -9) first. For an explanation see this question and answer: When should I not kill -9 a process?.

Your "trouble" killing firefox might be a direct result of a previous kill -9 (or pkill -9). Firefox maintains lockfiles in the profile directory. The lockfiles are there to prevent two instances of firefox accessing the same profile at the same time. Normally firefox removes the lockfiles before it terminates. If you kill -9 firefox then firefox is killed instantly and cannot remove the lockfiles. If you kill (without -9) then firefox can still remove the lockfiles before terminating.

I think this is what happened in your case:

  1. Firefox is running. Lockfiles in your profile dir.
  2. You did pkill -9 -f firefox. Firefox is terminated instanly. Lockfiles still in your profile dir.
  3. You try to start a new firefox process. The new firefox process sees the lockfiles in the profile directory and thinks that another firefox process is still running and refuses to start. The error message it gives you is really misleading.
  4. You think firefox was not killed previously and you are confused.

That is why you should not use kill -9 if not absolutely necessary, and most of the time it is not absolutely necessary.

If you are sure that firefox is killed (check with pgrep -fl firefox) you can manually remove the lockfiles from your profile. For more information see this mozillazine article: http://kb.mozillazine.org/Profile_in_use.

Related Question