projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
57acb38
)
Detect a debugger.
author
Scott Gasch
<
[email protected]
>
Sun, 5 Jun 2022 05:33:12 +0000
(22:33 -0700)
committer
Scott Gasch
<
[email protected]
>
Sun, 5 Jun 2022 05:33:12 +0000
(22:33 -0700)
misc_utils.py
patch
|
blob
|
history
diff --git
a/misc_utils.py
b/misc_utils.py
index f844f721bdacd5741719c1719593e09fd2d69036..669b3ef98a20d2b4144da67299c463f73ee46851 100644
(file)
--- 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