tools/ustat: Properly handle SIGINT in ustat#5498
Open
jeromemarchand wants to merge 1 commit intoiovisor:masterfrom
Open
tools/ustat: Properly handle SIGINT in ustat#5498jeromemarchand wants to merge 1 commit intoiovisor:masterfrom
jeromemarchand wants to merge 1 commit intoiovisor:masterfrom
Conversation
Most interactive tools waiting for a keyboard interrupt just expect it
during sleep() call. In most case it works well enough since most of
the time is typically spend in sleep. In the case of tclstat however, the
tool can spend a lot of time detaching uprobes, in self.bpf.cleanup() more
specifically and it fails when CTRL+C is pressed.
Fix this by catching the SIGINT signal. We still want to raise
KeyboardInterrupt while sleeping though, for the tool to exit
immediately when possible.
Fixes the following error:
10:12:42 loadavg: 0.03 0.05 0.01 2/289 21928
PID CMDLINE METHOD/s GC/s OBJNEW/s CLOAD/s EXC/s THR/s
21926 tclsh ./fib.tcl 2 2 0 8 0 0 0
^Cioctl(PERF_EVENT_IOC_DISABLE) failed: Bad file descriptor
close perf event FD failed: Bad file descriptor
Exception ignored in atexit callback: <bound method BPF.cleanup of <bcc.BPF object at 0x7f00481bbc20>>
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/bcc/__init__.py", line 1855, in cleanup
self.detach_uprobe_event(k)
File "/usr/lib/python3.12/site-packages/bcc/__init__.py", line 1507, in detach_uprobe_event
raise Exception("Failed to detach BPF from uprobe")
Exception: Failed to detach BPF from uprobe
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most interactive tools waiting for a keyboard interrupt just expect it during sleep() call. In most case it works well enough since most of the time is typically spend in sleep. In the case of tclstat however, the tool can spend a lot of time detaching uprobes, in self.bpf.cleanup() more specifically and it fails when CTRL+C is pressed.
Fix this by catching the SIGINT signal. We still want to raise KeyboardInterrupt while sleeping though, for the tool to exit immediately when possible.
Fixes the following error:
10:12:42 loadavg: 0.03 0.05 0.01 2/289 21928
PID CMDLINE METHOD/s GC/s OBJNEW/s CLOAD/s EXC/s THR/s
21926 tclsh ./fib.tcl 2 2 0 8 0 0 0
^Cioctl(PERF_EVENT_IOC_DISABLE) failed: Bad file descriptor
close perf event FD failed: Bad file descriptor
Exception ignored in atexit callback: <bound method BPF.cleanup of <bcc.BPF object at 0x7f00481bbc20>>
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/bcc/init.py", line 1855, in cleanup
self.detach_uprobe_event(k)
File "/usr/lib/python3.12/site-packages/bcc/init.py", line 1507, in detach_uprobe_event
raise Exception("Failed to detach BPF from uprobe")
Exception: Failed to detach BPF from uprobe