[tor-commits] [torflow/master] Only try to kill tor if it is our process and it exists

aagbsn at torproject.org aagbsn at torproject.org
Mon Oct 13 13:35:54 UTC 2014


commit d97b0527893fc54a39d31823a925c46748bfd66e
Author: Peter Palfrader <peter at palfrader.org>
Date:   Fri Jul 13 13:41:35 2012 +0200

    Only try to kill tor if it is our process and it exists
---
 NetworkScanners/BwAuthority/run_scan.sh |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/NetworkScanners/BwAuthority/run_scan.sh b/NetworkScanners/BwAuthority/run_scan.sh
index 4577b62..6108172 100755
--- a/NetworkScanners/BwAuthority/run_scan.sh
+++ b/NetworkScanners/BwAuthority/run_scan.sh
@@ -21,9 +21,11 @@ done
 KILLED_TOR=false
 if [ -f "./data/tor/tor.pid" ]; then
   PID=`cat ./data/tor/tor.pid`
-  kill $PID
-  if [ $? -eq 0 ]; then
-    KILLED_TOR=true
+  if kill -0 "$PID" 2>/dev/null; then # it is a running process and we may send signals to it
+    kill $PID
+    if [ $? -eq 0 ]; then
+      KILLED_TOR=true
+    fi
   fi
 fi
 





More information about the tor-commits mailing list