-
Notifications
You must be signed in to change notification settings - Fork 4k
tools/ustat: Properly handle SIGINT in ustat #5498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |||||||||||||||
| import sys | ||||||||||||||||
| from subprocess import call | ||||||||||||||||
| from time import sleep, strftime | ||||||||||||||||
| import signal | ||||||||||||||||
|
|
||||||||||||||||
| class Category(object): | ||||||||||||||||
| THREAD = "THREAD" | ||||||||||||||||
|
|
@@ -242,10 +243,17 @@ def _detach_probes(self): | |||||||||||||||
| self.bpf.cleanup() # Cleans up all attached probes | ||||||||||||||||
| self.bpf = None | ||||||||||||||||
|
|
||||||||||||||||
| def _sigint_handler(self, signum, frame): | ||||||||||||||||
| self.exiting = True; | ||||||||||||||||
| if self.in_sleep: | ||||||||||||||||
| raise KeyboardInterrupt | ||||||||||||||||
|
Comment on lines
+246
to
+249
|
||||||||||||||||
|
|
||||||||||||||||
| def _loop_iter(self): | ||||||||||||||||
| self._attach_probes() | ||||||||||||||||
| try: | ||||||||||||||||
| self.in_sleep = True | ||||||||||||||||
| sleep(self.args.interval) | ||||||||||||||||
| self.in_sleep = False | ||||||||||||||||
|
Comment on lines
251
to
+256
|
||||||||||||||||
| except KeyboardInterrupt: | ||||||||||||||||
| self.exiting = True | ||||||||||||||||
|
Comment on lines
+256
to
258
|
||||||||||||||||
| self.in_sleep = False | |
| except KeyboardInterrupt: | |
| self.exiting = True | |
| except KeyboardInterrupt: | |
| self.exiting = True | |
| finally: | |
| self.in_sleep = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.exiting = True;ends with a semicolon, which triggers pycodestyle E703 (andscripts/py-style-check.shruns pycodestyle overtools/**/*.py). Remove the trailing semicolon to avoid CI/style check failures.