Created
March 2, 2015 05:32
-
-
Save Noitidart/730edc0d3517483b5100 to your computer and use it in GitHub Desktop.
_ff-addon-snippet-NsiProcessNoPidPollution - On Mac to prevent PID pollution when launching other files, the solution was to use /usr/bin/open
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.time('nsIProcess runAsync'); | |
var open = new FileUtils.File('/usr/bin/open', []); | |
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess); | |
process.init(open); | |
var args = ['-a', '/Users/noit/Library/Application Support/Firefox/profilist_data/profile_launchers/Firefox - cust.app']; | |
/* | |
if (url) { | |
if (OS.Constants.Sys.Name != 'WINNT') { | |
args.push('--args'); //for /usr/bin/open for nix/mac | |
} | |
args.push('about:home'); | |
args.push(url); | |
} | |
*/ | |
var cb = function(s, t, d) { | |
console.info('s:', s, 't:', t, 'd:', d); | |
console.timeEnd('nsIProcess runAsync'); | |
if (s.exitValue == 0) { | |
console.log('succesfully launched'); | |
} else if (s.exitValue == 1) { | |
console.warn('error 1 happend, did not launch, app may already be open'); | |
} else { | |
console.warn('an exitValue other then 0 or 1 happend i havent seen this happen yet in my couple days with it'); | |
} | |
} | |
process.runAsync(args, args.length, cb); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README
Rev1
Works
Here is the
run
method as opposed to therunAsync
method posted aboveUpdated description to make comments to make clear that this works or mac only, nix does not have
open
like this for that I had to useGio
see GitHubGIST :: Noitidart / _ff-addon-snippet-GioLaunch.js