Commit 3dfaf983 authored by 4ast's avatar 4ast

Merge pull request #262 from iovisor/bblanco_dev

Make KeyboardInterrupt catch more aggressive
parents 0b904997 d0c31819
......@@ -653,6 +653,7 @@ class BPF(object):
fields (task, pid, cpu, flags, timestamp, msg) or None if no
line was read (nonblocking=True)
"""
try:
while True:
line = self.trace_readline(nonblocking)
if not line and nonblocking: return (None,) * 6
......@@ -665,6 +666,8 @@ class BPF(object):
cpu = cpu[1:-1]
msg = line[ts_end + 4:]
return (task, int(pid), int(cpu), flags, float(ts), msg)
except KeyboardInterrupt:
exit()
def trace_readline(self, nonblocking=False):
"""trace_readline(nonblocking=False)
......@@ -693,6 +696,7 @@ class BPF(object):
example: trace_print(fmt="pid {1}, msg = {5}")
"""
try:
while True:
if fmt:
fields = self.trace_fields(nonblocking=False)
......@@ -702,6 +706,8 @@ class BPF(object):
line = self.trace_readline(nonblocking=False)
print(line)
sys.stdout.flush()
except KeyboardInterrupt:
exit()
@staticmethod
def _load_kallsyms():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment