Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
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
    
“Firefox is already running, but is not responding.” sounds like a good reason for involving SIGKILL. –  manatwork Mar 7 '13 at 9:52
    
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
add comment

3 Answers

up vote 3 down vote accepted

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. See here for more explanation.

I think that your "trouble" killing firefox is a direct result of your 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. See here for more information.

share|improve this answer
add comment

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.

share|improve this answer
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
add comment

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

share|improve this answer
1  
pidof firefox must be between backticks, they don't seem to appear for whatever reason. –  schaiba Mar 7 '13 at 9:46
2  
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
show 4 more comments

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.