Your firefox is already dead. You think it is still running because of a misleading error message (*). This is most likely a result of the previous kill -9
.
Do not use kill -9
if not absolutely necessary. And most of the time it is not absolutely necessary.
This is what I think happened in your case:
- Firefox is running.
- You did
pkill -9 -f firefox
. Firefox is killed instantly (**). As such it did not had the chance to remove its lockfiles from the profile directory.
- You start a new firefox process.
- The new firefox process sees the lockfiles still in the profile directory and thinks that another firefox process is still running. It then refuses to start with the misleading error message.
- You are confused by the error message and think that firefox was not killed previously.
- You keep trying to kill firefox which has no effect because there is no firefox process running. At the same time you keep getting the same misleading error message because the lockfiles are still in place.
If you are sure that firefox is killed (check with pgrep -fl firefox
) you can manually remove the lockfiles from the profile directory. For more information see this mozillazine article: http://kb.mozillazine.org/Profile_in_use.
(*) The error message is misleading because it says another process is running even though it does not actually check for another process. It just checks for the lockfiles. So the error message is just an indicator for the lockfile. Not necessarily for another process.
(**) Killed instantly as opposed to given the chance to clean up before terminating on its own terms. While killed instantly is the intended effect of kill -9
the consequences are often neither intended nor expected by the user.
Read on for more elaboration about this.
Background info:
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.
If you start firefox it will check for the lockfiles first. If there are no lockfiles then firefox will place it's own lockfiles and start normally. If there already are lockfiles then firefox will assume that this profile is used by another instance of firefox and show a misleading error message that there already is an instance running.
misleading because firefox only checks for the lockfiles. It does not check whether there are actual firefox processes running. Sometimes there are no other firefox instances running. Just the lockfiles left over.
If you close firefox normaly (mouse click on close button or alt+f4
) it will not terminate immediately. Instead it will start a "shut down routine". That includes, among other, removing the lockfiles. If you observe the processes (for example using top
) you will notice firefox not disappearing immediately from the process list.
If you kill
firefox (without -9
) it will not "kill" firefox. Instead it sends a signal. A signal named SIGTERM
for terminate; commonly understood as the signal to "shut down now". Upon receiving the signal firefox will start the shut down routine as above.
If you press ctrl+c
in a terminal (with firefox running from the same terminal) it will also send a signal. This time it is SIGINT
for interrupt. This is semantically the same as SIGTERM
for most end user programs. Firefox will start the shut down routine.
(side note: programs are not required to shutdown upon receiving these signals. some programs will do some specific work and then keep running. but this is not common in end user programs)
kill -9
is different. If you kill -9
firefox will not get a signal. It will not start the shut down routine. Instead it just ceases to exists. On the spot. Midstep. Anything left unwritten on disk will be lost. And, conversely, anything still on disk will stay on disk. The lockfiles will stay on disk.
Firefox, killed instantly with kill -9
, had no chance to start the shut down routine and as such couldn't remove the lockfiles. Then, when you start firefox again, it will see the lockfiles and it will refuse to start with the misleading error message.
That is why you should not use kill -9
if not absolutely necessary, and most of the time it is not absolutely necessary.
For more discussion about why not kill -9
read this question and answer (and comments): When should I not kill -9 a process?.
For more info on signals: https://en.wikipedia.org/wiki/Signal_(IPC)
SIGKILL
. – manatwork Mar 07 '13 at 09:52SIGKILL
can't be handled by programs, so they can't perform any cleanup. In the case of Firefox this probably prevents it from getting rid of the profile lock. If you are just trying to terminate firefox normally, useSIGTERM
. – njsg Mar 07 '13 at 14:33-9
) isSIGKILL
, seeman 7 signal
.) – njsg Mar 07 '13 at 14:33