[Pkg-javascript-commits] [pdf.js] 40/141: Using shell/cmd commands to kill browser tasks

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 22:40:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit b72094d74054df465e9e4a402daf7b00c6a1ab92
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Mon Apr 7 07:59:27 2014 -0500

    Using shell/cmd commands to kill browser tasks
---
 test/webbrowser.js | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/test/webbrowser.js b/test/webbrowser.js
index f7354f1..69c6333 100644
--- a/test/webbrowser.js
+++ b/test/webbrowser.js
@@ -66,28 +66,29 @@ WebBrowser.prototype = {
     var proc = spawn(this.path, args);
     proc.on('exit', function (code) {
       this.finished = true;
-      // trying to wait for process to shutdown (for Windows sake)
-      setTimeout(function () {
-        this.cleanup();
-        if (this.callback) {
-          this.callback.call(null, code);
-        }
-      }.bind(this), 500);
+      this.cleanup(this.callback && this.callback.bind(null, code));
     }.bind(this));
     return proc;
   },
-  cleanup: function () {
+  cleanup: function (callback) {
     try {
       testUtils.removeDirSync(this.tmpDir);
+      this.process = null;
+      callback();
     } catch (e) {
       console.error('Unable to cleanup after the process: ' + e);
       try {
         if (this.process) {
-          this.process.kill('SIGKILL');
+          var pid = this.process.pid;
+          if (process.platform === 'win32') {
+            // kill does not really work on windows
+            spawn('taskkill', ['-F', '-PID', pid]).on('exit', callback);
+          } else {
+            spawn('kill', ['-s', 'SIGKILL', pid]).on('exit', callback);
+          }
         }
       } catch (e) {}
     }
-    this.process = null;
   },
   stop: function (callback) {
     if (this.finished) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list