4

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.

5
  • 1
    -9 isn't appropriate for most programs, use it for a shell only. With -9 a program can't do any cleanup. Try -15 instead.
    – ott--
    Mar 7 '13 at 9:46
  • 1
    “Firefox is already running, but is not responding.” sounds like a good reason for involving SIGKILL.
    – manatwork
    Mar 7 '13 at 9:52
  • 1
    In my experience, firefox takes some time before the "already running, not responding" gets cleared up.
    – vonbrand
    Mar 7 '13 at 10:13
  • 1
    SIGKILL 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, use SIGTERM.
    – njsg
    Mar 7 '13 at 14:33
  • (Also, if you're not aware, signal 9 (-9) is SIGKILL, see man 7 signal.)
    – njsg
    Mar 7 '13 at 14:33
8

Do not use kill -9 if not absolutely necessary. Always try kill (without -9) first.

Your trouble "killing" firefox is likely be a result of a previous kill -9 (or pkill -9).

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 killed instanly. Lockfiles still in your profile dir.
  3. You start a new firefox process.
  4. The new firefox process sees the lockfiles in the profile directory and thinks that another firefox process is still running and refuses to start with a misleading error message.
  5. You are confused by the error message and think that firefox was not killed previously.
  6. You try to keep killing firefox which has no effect because there is no firefox process running.

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.

For more explanation about why not kill -9 see this question and answer: When should I not kill -9 a process?.


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 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 the (potentially misleading) error message that there already is an instance running.

The error message can be misleading because firefox only checks for the lockfiles. It does not check whether there actually are firefox processes running. Sometimes there really are no other firefox instances running. it is just the lockfiles that are left over from a previous instance that for whatever reason were not deleted correctly.

If you close firefox normally it will do some maintenance work before actually shutting down. If you observe the processes (for example using top) you will notice firefox not disappearing immediately from the process list. also that firefox is using a lot of processor at this time. Among other work that firefox is doing at this time is to remove the lockfiles so that the profile will be free to use for the next invocation of firefox.

If you kill firefox (without -9) then firefox will try to shutdown quickly but it will still do some maintenance work like deleting the lockfiles. that also means that firefox will not disappear instantly from the list of processes.

This is actually normal and expected behavious of software. Many software have some state in working memory that is prudent to save to disk upon termination. If termination is requested (by the user clicking the close button, by a kill without -9, or by ctrl+c in the terminal) the software gets notified of this and will start to do the maintenance work and then terminate.

If you kill -9 a process then that process will not get notified of the termination request instead it is killed instantly. if you kill -9 firefox then firefox is killed instantly and cannot remove the lockfiles. and the next time you start firefox you will get 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.

1
  • "You think firefox was not killed and you are confused". Okay, 99% likelihood you are right. In my decades of Unix experience I had never seen a process survive kill -9. Until today. Firefox is using up 100% of the CPU and kill -9 is not stopping it. I cannot attach to a debugger as that requires a signal as well, but I'm pretty sure it's a problem in the kernel (Linux 4.9.0). dmesg shows some "hung_task" messages about the zombie children (which did die), but nothing about the parent process. I'm flabbergasted.
    – hackerb9
    Sep 13 '21 at 23:02
6

As far as I know, firefox creates a file called lockor something like that in ~/.mozilla/firefox/<your_profile>/ when it is executed. I don't know the exact behaviour, but sometimes it hinders you to run a second instance of firefox, or, if it is not deleted after closing firefox, to run a single instance at all. Try deleting this file, it should help.

1
  • 3
    If there is no firefox process running (which is likely the case, after all processes can't ignore SIGKILL), this is likely to be the cause of the error message.
    – njsg
    Mar 7 '13 at 14:30
0

I noticed this recently. You'll need to do pkill -9 GeckoMain. or pkill -f -9 firefox. If you look at /proc/<pid of a firefox>/comm, it doesn't say firefox.

Hope that helps

-1

In my own experience, Firefox can sometimes take a minute (or even more) to finally shut down completely, as shown by system monitor. I don't know about Red Hat, but if you have system monitor, you might try using it to see if Firefox is still running, and if it is again from there give the kill command. That should do it.

1
  • 1
    I do realize the OP was not specifically asking for the information I provided in my answer but I was trying to help by emphasizing this fact about Firefox. I don't think it was really necessary to downvote my answer twice. Feb 11 '18 at 5:45
-4

Try kill -9 `pidof firefox` and wait for a few seconds.

9
  • 1
    pidof firefox must be between backticks, they don't seem to appear for whatever reason.
    – schaiba
    Mar 7 '13 at 9:46
  • 3
    Better use $() instead of backticks. (GreyCat's Why is $(...) preferred over ... (backticks)? article enumerates additional reasons.)
    – manatwork
    Mar 7 '13 at 9:47
  • @schaiba I am seeing a "pidof: Command not found."
    – Geek
    Mar 7 '13 at 9:48
  • Try @manatwork's solution, then.
    – schaiba
    Mar 7 '13 at 9:54
  • @schaiba, if says “Command not found”, that sounds like the sysvinit-tools package (the one containing pidof on my system) is not installed there.
    – manatwork
    Mar 7 '13 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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