diff options
| author | Scott Gasch <[email protected]> | 2022-06-04 22:33:12 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-06-04 22:33:12 -0700 |
| commit | 903843730a9916105352c729e94136a755b5e529 (patch) | |
| tree | 428afed5b51c41f9414438e12481ff9ae307ecfb /misc_utils.py | |
| parent | 57acb381eb927bcafd5a0c496e4fec8917f361a7 (diff) | |
Detect a debugger.
Diffstat (limited to 'misc_utils.py')
| -rw-r--r-- | misc_utils.py | 8 |
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 |
