Skip to content

Commit e12ec04

Browse files
chenhengqiyonghong-song
authored andcommitted
tools/kvmexit: Display header after KeyboardInterrupt
When Ctrl+C is hit, `^C` messes up the output header. Fix that by adding a blank line before printing. Also remove unused import and signal handler. Signed-off-by: Hengqi Chen <[email protected]>
1 parent 48a9bf5 commit e12ec04

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tools/kvmexit.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@
2828

2929

3030
from __future__ import print_function
31-
from time import sleep, strftime
31+
from time import sleep
3232
from bcc import BPF
3333
import argparse
3434
import multiprocessing
3535
import os
36-
import signal
3736
import subprocess
3837

3938
#
@@ -323,15 +322,11 @@ def find_tid(tgt_dir, tgt_vcpu):
323322
print(" after sleeping %d secs." % duration)
324323
else:
325324
print("... Hit Ctrl-C to end.")
326-
print("%s%-35s %s" % (header_format, "KVM_EXIT_REASON", "COUNT"))
327325

328-
# signal handler
329-
def signal_ignore(signal, frame):
330-
print()
331326
try:
332327
sleep(duration)
333328
except KeyboardInterrupt:
334-
signal.signal(signal.SIGINT, signal_ignore)
329+
print()
335330

336331

337332
# Currently, sort multiple tids in descending order is not supported.
@@ -341,6 +336,8 @@ def signal_ignore(signal, frame):
341336
tgid_exit = [0 for i in range(len(exit_reasons))]
342337

343338
# output
339+
print("%s%-35s %s" % (header_format, "KVM_EXIT_REASON", "COUNT"))
340+
344341
pcpu_kvm_stat = b["pcpu_kvm_stat"]
345342
pcpu_cache = b["pcpu_cache"]
346343
for k, v in pcpu_kvm_stat.items():

0 commit comments

Comments
 (0)