Skip to content

Commit

Permalink
if instruments chooses not to die, leave it in its grave and find ano…
Browse files Browse the repository at this point in the history
…ther one
  • Loading branch information
jlipps committed Dec 19, 2013
1 parent 049f9a6 commit 2622b25
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/devices/ios/instruments.js
Expand Up @@ -20,6 +20,8 @@ var ERR_NEVER_CHECKED_IN = "Instruments never checked in"
var Instruments = function(opts) {
this.app = opts.app;
this.launchTimeout = opts.launchTimeout || 90000;
this.killTimeout = 6000;
this.killTimer = null;
this.flakeyRetries = opts.flakeyRetries;
this.launchTries = 0;
this.neverConnected = false;
Expand Down Expand Up @@ -116,6 +118,11 @@ Instruments.prototype.launchHandler = function(err) {
Instruments.prototype.killProc = function() {
if (this.proc !== null) {
logger.info("Sending sigkill to instruments");
this.killTimer = setTimeout(function() {
logger.info("Instruments didn't die after " + (this.killTimeout / 1000) +
" seconds; abandoning it completely");
this.onInstrumentsExit(1);
}.bind(this), this.killTimeout);
this.proc.kill('SIGKILL');
}
};
Expand Down Expand Up @@ -257,6 +264,7 @@ Instruments.prototype.spawnInstruments = function(tmpDir) {
};

Instruments.prototype.onInstrumentsExit = function(code) {
clearTimeout(this.killTimer);
this.debug("Instruments exited with code " + code);

if (this.neverConnected) {
Expand Down

0 comments on commit 2622b25

Please sign in to comment.