Sorry, forgot to CC linux-rt-users@xxxxxxxxxxxxxxx On 2021-08-06 16:01 +0200, Jan Hutař wrote:
Hello. I wanted to use hwlatdetect in this way: nohup ./hwlatdetect --duration <long time> ... & pid=$! <run my workload> kill -s 2 $pid but as I'm running these in different shells (in individual ansible tasks), sending SIGINT does not work as Python is not registering it properly: https://stackoverflow.com/questions/974189/how-to-send-a-sigint-to-python-from-a-bash-script I found it works for me with this patch (as advised on SO link above): # diff -u /usr/bin/hwlatdetect{.ORIG,} --- /usr/bin/hwlatdetect.ORIG 2021-08-06 13:46:18.781000725 +0000 +++ /usr/bin/hwlatdetect 2021-08-06 13:48:47.153994491 +0000 @@ -12,6 +12,7 @@ import subprocess import errno import os.path +import signal version = "0.8" debugging = False @@ -494,6 +495,11 @@ else: raise RuntimeError("invalid input for microseconds: '%s'" % str) + +def signal_handler(signum, frame): + raise KeyboardInterrupt("Signal handler") + + # # main starts here # @@ -501,6 +507,9 @@ if __name__ == '__main__': from argparse import ArgumentParser + # Properly register SIGINT signal (i.e. Ctrl+C) + signal.signal(signal.SIGINT, signal_handler) + parser = ArgumentParser() parser.add_argument("--duration", default=None, dest="duration", Please does this tiny patch make sense to you? It works for me. Thank you in advance, Jan -- Jan Hutar Performance Engineering jhutar@xxxxxxxxxx Red Hat, Inc.
-- Jan Hutar Performance Engineering jhutar@xxxxxxxxxx Red Hat, Inc.