Skip to content

Commit

Permalink
Revert "tools/biolatency: Handle signals from user"
Browse files Browse the repository at this point in the history
This reverts commit 87792ce.

Let us have a consensus about how bcc tools should interact with
external signals etc. before applying such changes to this tool
and other tools.
  • Loading branch information
yonghong-song committed Oct 1, 2020
1 parent 73cf23b commit 17e14ef
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions tools/biolatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from bcc import BPF
from time import sleep, strftime
import argparse
import signal

# arguments
examples = """examples:
Expand Down Expand Up @@ -194,7 +193,15 @@ def flags_print(flags):
desc = "NoWait-" + desc
return desc

def print_hist():
# output
exiting = 0 if args.interval else 1
dist = b.get_table("dist")
while (1):
try:
sleep(int(args.interval))
except KeyboardInterrupt:
exiting = 1

print()
if args.timestamp:
print("%-8s\n" % strftime("%H:%M:%S"), end="")
Expand All @@ -205,28 +212,6 @@ def print_hist():
dist.print_log2_hist(label, "disk")
dist.clear()

def exit_handler():
print_hist()
exit()

def signal_handler(sig, frame):
exit_handler()

signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGQUIT, signal_handler)

exiting = 0 if args.interval else 1
dist = b.get_table("dist")

while (1):
try:
sleep(int(args.interval))
except KeyboardInterrupt:
exiting = 1

print_hist()

countdown -= 1
if exiting or countdown == 0:
exit_handler()
exit()

0 comments on commit 17e14ef

Please sign in to comment.