The weird effects of Firefox's remote control on Unix

January 23, 2008

I hope that Firefox's remote control feature is reasonably well known, but I suspect most people don't know about the surprising and relatively weird effects it has in the Unix version of Firefox; certainly it surprised my co-workers when they stumbled across it.

(Remote control is the feature where if you already have a running Firefox and try to start another one, it will just open a new browser window (or tab) in the first one.)

The root of the surprising behavior comes from how Firefox's remote control works. Rather than use a conventional IPC mechanism (Unix domain sockets, for example), instances of Firefox communicate with each other through X properties. Because X properties are not a per machine thing like Unix domain sockets, the Firefox remote control is global; a Firefox on a machine that you've ssh'd in to can remote control your local Firefox (and vice versa).

(This is what surprised my co-workers; they expected it to be a per machine and per user thing.)

The default Firefox setup on Unix is quite insistent on using remote control if at all possible, to the point where it is impossible to start two copies of Firefox, even on different machines. This can periodically be annoying, for example if you really need to do some particular browsing from a specific machine but don't want to shut down your regular Firefox session.

(It can also be puzzling if you don't realize what's going on; you might find that downloaded files aren't where they're supposed to be, or that some machine's web-based control interface just doesn't seem to be responding.)

Fortunately this behavior is all in the firefox wrapper shell script, which you can modify to get around the issue; see the check_running function and where the ALREADY_RUNNING variable gets used. Note that having more than one Firefox running will make any remote control stuff you do potentially confusing, since you don't know which one will get remote controlled.

Comments on this page:

From at 2008-01-24 10:46:20:

Amusingly enough there's a race condition during startup, so if you've got two icons for different Firefox profiles and click quickly or you're just fast on the console you can launch two Firefox instances. I haven't looked into why you can't do two with the same profile, I'd assume it's just normal locking. I do this so that I can run an anonymous Firefox profile in parallel with the one that has cookies and yes, you do have issues with external links.

By Dan.Astoorian at 2008-01-24 14:40:02:

The default Firefox setup on Unix is quite insistent on using remote control if at all possible, to the point where it is impossible to start two copies of Firefox, even on different machines.

Actually, it is possible, though not at all well documented.

If the environment variable MOZ_NO_REMOTE is set to 1, Firefox will (generally) not use remote control. I frequently use something along the lines of:

   env MOZ_NO_REMOTE=1 firefox -P TestProfile

to launch Firefox using a different profile even while Firefox is already running on the same display using my default profile. This is useful if you want browsers running on different machines but using the same display (e.g., to view local documentation via file:// or http://localhost/ URLs), or to run multiple instances of the browser on the same machine (e.g., using different versions of Firefox, or using different profiles that have different extensions, bookmarks, etc.).

(One gotcha I've run into is that if you try to run a second instance of Firefox using the same profile, firefox will ignore MOZ_NO_REMOTE=1 rather than issue the usual "Firefox is already running" message.)


From at 2008-01-25 05:58:23:

Doesn't --no-remote take care of that? (At least, it used to.)


By cks at 2008-01-25 13:02:46:

The -no-remote command line switch does work. Interestingly, it's not documented in --help's output until very recently, although it does work. Note that it only has one dash, not two; the two dash version is quietly ignored, although some other Firefox switches use two dashes.

(It seems that two-dash switches are all things that are for low level libraries, while Firefox's top level switches all use only one dash.)

Some good reference for Firefox's various command line options are here and here.

From at 2008-01-26 10:13:26:

Oh jeez, no wonder it never seems to work for me any more. I guess I started quietly adding the second - at some point.

I'd like to thank GNU for making me used to using -- in front of long options.


From at 2008-04-17 05:35:51:

You can also just start Firefox with -no-remote.

Written on 23 January 2008.
« Linux's umount -f forces IO errors
Running a 32-bit Firefox on a 64-bit Fedora or Red Hat Enterprise »

Page tools: View Source, View Normal, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Jan 23 23:34:00 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.