Bug 1353656 - Use SubProcess.jsm from WebIDE instead of SDK equivalent. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 24 Jul 2017 19:23:09 +0200
changeset 419848 42801a80bc6c56509f385993bfee224edbf055d6
parent 419847 6c5ab3bb451d7063e96ccfbc4a70f56a322324a5
child 419849 df6fd4e616d9c09d2e8667ac8943397a5f774a6d
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1353656
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1353656 - Use SubProcess.jsm from WebIDE instead of SDK equivalent. r=jryans MozReview-Commit-ID: Lu0Ptuhopxh
devtools/client/webide/modules/simulator-process.js
--- a/devtools/client/webide/modules/simulator-process.js
+++ b/devtools/client/webide/modules/simulator-process.js
@@ -5,19 +5,20 @@
 
 "use strict";
 
 const { Cc, Ci, Cu } = require("chrome");
 
 const Environment = Cc["@mozilla.org/process/environment;1"]
                       .getService(Ci.nsIEnvironment);
 const EventEmitter = require("devtools/shared/event-emitter");
-const Subprocess = require("sdk/system/child_process/subprocess");
 const Services = require("Services");
 
+const {Subprocess} = Cu.import("resource://gre/modules/Subprocess.jsm", {});
+
 loader.lazyGetter(this, "OS", () => {
   switch (Services.appinfo.OS) {
     case "Darwin":
       return "mac64";
     case "Linux":
       if (Services.appinfo.XPCOMABI.indexOf("x86_64") === 0) {
         return "linux64";
       } else {
@@ -80,29 +81,40 @@ SimulatorProcess.prototype = {
       ["DISPLAY", "XAUTHORITY"]
         .filter(key => Environment.exists(key))
         .forEach(key => {
           environment.push(key + "=" + Environment.get(key));
         });
     }
 
     // Spawn a B2G instance.
-    this.process = Subprocess.call({
-      command: b2g,
+    Subprocess.call({
+      command: b2g.path,
       arguments: this.args,
+      environmentAppend: true,
       environment: environment,
-      stdout: data => this.emit("stdout", data),
-      stderr: data => this.emit("stderr", data),
+      stderr: "pipe",
+    }).then(process => {
+      this.process = process;
+      let dumpPipe = async (pipe, type) => {
+        let data = await pipe.readString();
+        while (data) {
+          this.emit(type, data);
+          data = await pipe.readString();
+        }
+      };
+      dumpPipe(process.stdout, "stdout");
+      dumpPipe(process.stderr, "stderr");
+
       // On B2G instance exit, reset tracked process, remote debugger port and
       // shuttingDown flag, then finally emit an exit event.
-      done: result => {
-        console.log("B2G terminated with " + result.exitCode);
+      process.wait().then(result => {
         this.process = null;
         this.emit("exit", result.exitCode);
-      }
+      });
     });
   },
 
   // Request a B2G instance kill.
   kill() {
     return new Promise(resolve => {
       if (this.process) {
         this.once("exit", (e, exitCode) => {