All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: possibility to gracefuly stop hwlatdetect when it is runinng in a background
       [not found] <20210806140103.3qpw5ldryml5tluw@localhost.localdomain>
@ 2021-08-06 14:01 ` Jan Hutař
  0 siblings, 0 replies; only message in thread
From: Jan Hutař @ 2021-08-06 14:01 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: Pradeep Surisetty, linux-rt-users

Sorry, forgot to CC linux-rt-users@vger.kernel.org

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@redhat.com     Red Hat, Inc.

-- 
Jan Hutar   Performance Engineering
jhutar@redhat.com     Red Hat, Inc.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-06 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210806140103.3qpw5ldryml5tluw@localhost.localdomain>
2021-08-06 14:01 ` possibility to gracefuly stop hwlatdetect when it is runinng in a background Jan Hutař

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.