Closed Bug 541929 Opened 15 years ago Closed 15 years ago

can't run multiple instances of a process with nsIProcess (NS_ERROR_ALREADY_INITIALIZED)

Categories

(Core :: XPCOM, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 497821

People

(Reporter: intendentedelleacque, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 Build Identifier: In one of my extension (ProfileSwitcher) i use the interface nsIProcess to run one or more instances of Firefox or Thunderbird with other profiles or with the profile manager. With gecko 1.9.2 I'm unable to do this, because of NS_ERROR_ALREADY_INITIALIZED. In fact if I launch from instance A the instance B and then - with B still running - the instance C, I get that error. I've tried several methods to solve this problem: - using runAsync instead of run - clone the nsIFile of the executable - set to null the this.process object before launching the new instance ( cfr. http://groups.google.com/group/mozilla.dev.apps.thunderbird/browse_thread/thread/01d8ab1bf0fdcf74) but nothing seems to work. It seems that once nsIProcess.init has been initialized, there is no way to de-initialized it. Notice that if i launch the instance B and then i close it, the nsIProcess object results still initialized; infact i can re-run the process just calling the run/runAsync method, without re-initialized the object. This didn't happen with gecko 1.8.1 and nsIProcess interface and with gecko 1.9.1 and nsIProcess2 interface. I know that in 1.9.2 has been added a check for repeated initialization, but this seems prevents totally to run more than one instance of the same program. In my opinion this is not correct, because it's perfectly proper to launche multiple instance of the same program. I've not made tests with other applications, but if the problem is present also with other applications, this could block many extensions. Reproducible: Always Steps to Reproduce: 1. initialize nsIProcess with a nsIFile pointing to firefox executable and "-no-remote" arg 2. call nsIProcess.run --> correctly another instance of firefox is launched 3. try again while the 2nd instance is still running Actual Results: You will get NS_ERROR_ALREADY_INITIALIZED, because there is no way to release the process object. Expected Results: There must be a way to release the process object, so that I can run multiple instance of the same programs.
Why not just create another nsIProcess instance?
(In reply to comment #1) > Dup of bug 497821? indeed
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
(In reply to comment #2) > Why not just create another nsIProcess instance? I get the same error
Are you using getService instead of createInstance? You should be using createInstance.
Ok many thanks, with createInstance it seems to work now. Using createInstance will work also with older version (gecko 1.8.1 and 1.9.1)? I've not a proof, but I'm quite sure that the getService was in some old documentation about nsIProcess. Anyway I've searched for dupes with NS_ERROR_ALREADY_INITIALIZED as parameter in comment but I didn't find anything, but probably it was my fault...sorry for the dupe.
Yes, createInstance will work everywhere.
You need to log in before you can comment on or make changes to this bug.