From 7202f102d91cb02e856ffdd422cfccf231cf9ce3 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Thu, 23 Apr 2015 09:57:09 +0900 Subject: [PATCH] Remove duplicate code. --- lib/units/device/plugins/screen/stream.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/units/device/plugins/screen/stream.js b/lib/units/device/plugins/screen/stream.js index a8359bd4..2c6a8083 100644 --- a/lib/units/device/plugins/screen/stream.js +++ b/lib/units/device/plugins/screen/stream.js @@ -289,7 +289,7 @@ module.exports = syrup.serial() }) } - function kindKill() { + function kill(signal) { if (pid <= 0) { return Promise.reject(new Error('Minicap service pid is unknown')) } @@ -297,26 +297,19 @@ module.exports = syrup.serial() log.info('Sending SIGTERM to minicap') return Promise.all([ waitForEnd() - , adb.shell(options.serial, ['kill', pid]) + , adb.shell(options.serial, ['kill', signal, pid]) .then(adbkit.util.readAll) .timeout(2000) .return(true) ]) } - function forceKill() { - if (pid <= 0) { - return Promise.reject(new Error('Minicap service pid is unknown')) - } + function kindKill() { + return kill('-15') + } - log.info('Sending SIGKILL to minicap') - return Promise.all([ - waitForEnd() - , adb.shell(options.serial, ['kill', '-9', pid]) - .then(adbkit.util.readAll) - .timeout(2000) - .return(true) - ]) + function forceKill() { + return kill('-9') } function forceEnd() {