summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2022-06-04 22:33:12 -0700
committerScott Gasch <[email protected]>2022-06-04 22:33:12 -0700
commit903843730a9916105352c729e94136a755b5e529 (patch)
tree428afed5b51c41f9414438e12481ff9ae307ecfb
parent57acb381eb927bcafd5a0c496e4fec8917f361a7 (diff)
Detect a debugger.
-rw-r--r--misc_utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/misc_utils.py b/misc_utils.py
index f844f72..669b3ef 100644
--- a/misc_utils.py
+++ b/misc_utils.py
@@ -5,6 +5,7 @@
"""Miscellaneous utilities."""
import os
+import sys
def is_running_as_root() -> bool:
@@ -16,6 +17,13 @@ def is_running_as_root() -> bool:
return os.geteuid() == 0
+def debugger_is_attached() -> bool:
+ """Return if the debugger is attached"""
+
+ gettrace = getattr(sys, 'gettrace', lambda: None)
+ return gettrace() is not None
+
+
if __name__ == '__main__':
import doctest