[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Replacing isTorRunning() with stem util
commit 12ef6f0b5092745fb4fa442207306907204530e7
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon May 27 21:46:08 2013 -0700
Replacing isTorRunning() with stem util
Dropping our isTorRunning() helper function in favour of a stem utility that
strives to be quite a bit more through.
---
src/starter.py | 2 +-
src/util/torTools.py | 34 ----------------------------------
2 files changed, 1 insertion(+), 35 deletions(-)
diff --git a/src/starter.py b/src/starter.py
index 303c342..840e914 100644
--- a/src/starter.py
+++ b/src/starter.py
@@ -357,7 +357,7 @@ if __name__ == '__main__':
# - tor is running (otherwise it would be kinda confusing, "tor is running
# but why does arm say that it's shut down?")
- if util.torTools.isTorRunning():
+ if len(stem.util.system.get_pid_by_name('tor', multiple = True)) >= 1:
config.set("features.allowDetachedStartup", "false")
# syncs config and parameters, saving changed config options and overwriting
diff --git a/src/util/torTools.py b/src/util/torTools.py
index 62898d5..9fc396b 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -51,40 +51,6 @@ REQ_EVENTS = {"NEWDESC": "information related to descriptors will grow stale",
"NS": "information related to the consensus will grow stale",
"NEWCONSENSUS": "information related to the consensus will grow stale"}
-def isTorRunning():
- """
- Simple check for if a tor process is running. If this can't be determined
- then this returns False.
- """
-
- # Linux and the BSD families have different variants of ps. Guess based on
- # os.uname() results which to try first, then fall back to the other.
- #
- # Linux
- # -A - Select all processes. Identical to -e.
- # -co command - Shows just the base command.
- #
- # Mac / BSD
- # -a - Display information about other users' processes as well as
- # your own.
- # -o ucomm= - Shows just the ucomm attribute ("name to be used for
- # accounting")
-
- primaryResolver, secondaryResolver = "ps -A co command", "ps -ao ucomm="
-
- if os.uname()[0] in ("Darwin", "FreeBSD", "OpenBSD"):
- primaryResolver, secondaryResolver = secondaryResolver, primaryResolver
-
- commandResults = system.call(primaryResolver)
- if not commandResults:
- commandResults = system.call(secondaryResolver)
-
- if commandResults:
- for cmd in commandResults:
- if cmd.strip() == "tor": return True
-
- return False
-
def getConn():
"""
Singleton constructor for a Controller. Be aware that this starts as being
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits