From 09db0dbe1a29cb183ad145bbd05d7ec0c2e01f33 Mon Sep 17 00:00:00 2001 From: Piratmac <6253139+Piratmac@users.noreply.github.com> Date: Wed, 14 Oct 2020 08:52:18 +0200 Subject: [PATCH 1/2] isRunning: check if process is still running --- index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index da6cf3e..3b43ac4 100755 --- a/index.js +++ b/index.js @@ -56,7 +56,18 @@ function logError(description) { } function isRunning() { - return shell.test('-f', pidFile); + if (!shell.test('-f', pidFile)) { + return 0 + } + else { + try { + pid = fs.readFileSync(pidFile) + return process.kill(pid,0) + } + catch (e) { + return e.code === 'EPERM' + } + } } From d36841d911fb386b7cd982fce9d85a2e0d1071f1 Mon Sep 17 00:00:00 2001 From: Piratmac <6253139+Piratmac@users.noreply.github.com> Date: Tue, 23 May 2023 08:40:11 +0200 Subject: [PATCH 2/2] Removed unnecessary "if" Co-authored-by: Dov Benyomin Sohacheski --- index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 3b43ac4..f7c2e62 100755 --- a/index.js +++ b/index.js @@ -59,14 +59,12 @@ function isRunning() { if (!shell.test('-f', pidFile)) { return 0 } - else { - try { - pid = fs.readFileSync(pidFile) - return process.kill(pid,0) - } - catch (e) { - return e.code === 'EPERM' - } + try { + pid = fs.readFileSync(pidFile) + return process.kill(pid,0) + } + catch (e) { + return e.code === 'EPERM' } }