As the title suggests I have this python/bcc program that doesn't stop when pressing KeyboardInterrupt, i have to hold it. The code is as follows:
def callback(ctx, data, size):
event = bpf["syscalls"].event(data)
if syscall_name(event.syscall_id).decode('utf-8') not in filter_syscalls and event.comm.decode('utf-8') not in filter_comms and event.pid not in filter_pid:
print(event.pid)
print(filter_pid)
bpf = BPF(text=text)
bpf["syscalls"].open_ring_buffer(callback)
while 1:
try:
bpf.ring_buffer_poll()
except KeyboardInterrupt:
sys.exit()
EDIT: I added a time.sleep(0.5) to the try block and it now stops when I press ctrl+c, might be losing events though.