All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Maciej Falkowski <maciej.falkowski9@gmail.com>
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>
Subject: Re: [PATCH 2/2] Makefile: clang-tools: Omit printing stack trace when KeyboardInterrupt is raised
Date: Fri, 21 May 2021 10:17:52 -0700	[thread overview]
Message-ID: <CAKwvOd=32_yNvAWRjyczOoEjsWje9SfaB=S1s9kS1bRFZhuU8g@mail.gmail.com> (raw)
In-Reply-To: <20210520231821.12272-2-maciej.falkowski9@gmail.com>

On Thu, May 20, 2021 at 4:18 PM Maciej Falkowski
<maciej.falkowski9@gmail.com> wrote:
>
> When user terminates the script (also implicitly through for example
> `make clang-analyzer`) by using
> Ctrl+C (or sending SIGINT more generally) the KeyboardInterrupt
> is raised printing stack trace of the execution as shown below:
>
> $ ./scripts/clang-tools/run-clang-tools.py clang-tidy ./compile_commands.json
> ^CTraceback (most recent call last):
>   File "./scripts/clang-tools/run-clang-tools.py", line 74, in <module>
>     main()
>   File "./scripts/clang-tools/run-clang-tools.py", line 70, in main
>     pool.map(run_analysis, datastore)
>   File "/usr/lib64/python3.8/multiprocessing/pool.py", line 364, in map
>     return self._map_async(func, iterable, mapstar, chunksize).get()
>   File "/usr/lib64/python3.8/multiprocessing/pool.py", line 765, in get
>     self.wait(timeout)
>   File "/usr/lib64/python3.8/multiprocessing/pool.py", line 762, in wait
>     self._event.wait(timeout)
>   File "/usr/lib64/python3.8/threading.py", line 558, in wait
> Process ForkPoolWorker-6:
> Process ForkPoolWorker-1:
> Process ForkPoolWorker-5:
> Process ForkPoolWorker-7:
> Process ForkPoolWorker-2:
> Process ForkPoolWorker-3:
> Process ForkPoolWorker-4:
> Process ForkPoolWorker-8:
>     signaled = self._cond.wait(timeout)
>   File "/usr/lib64/python3.8/threading.py", line 302, in wait
>     waiter.acquire()
> KeyboardInterrupt

With this applied,
$ make LLVM=1 LLVM_IAS=1 -j72 clang-analyzer
^C
Process ForkPoolWorker-5:
make: *** [Makefile:1902: clang-analyzer] Error 130

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks for the patch!

> The patch handles the raise of the KeyboardInterrupt and exits when occurred
> with code 130 as documented in: https://tldp.org/LDP/abs/html/exitcodes.html
>
> Signed-off-by: Maciej Falkowski <maciej.falkowski9@gmail.com>
> ---
>  scripts/clang-tools/run-clang-tools.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
> index 38fc311d2e03..eb0e0ecfce24 100755
> --- a/scripts/clang-tools/run-clang-tools.py
> +++ b/scripts/clang-tools/run-clang-tools.py
> @@ -77,4 +77,7 @@ def main():
>
>
>  if __name__ == "__main__":
> -    main()
> +    try:
> +        main()
> +    except KeyboardInterrupt:
> +        sys.exit(130)
> --
> 2.26.3
>


-- 
Thanks,
~Nick Desaulniers

  reply	other threads:[~2021-05-21 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 23:18 [PATCH 1/2] Makefile: clang-tools: Print information when clang-tidy tool is missing Maciej Falkowski
2021-05-20 23:18 ` [PATCH 2/2] Makefile: clang-tools: Omit printing stack trace when KeyboardInterrupt is raised Maciej Falkowski
2021-05-21 17:17   ` Nick Desaulniers [this message]
2021-05-22  3:03     ` Masahiro Yamada
2021-06-15 19:57       ` Maciej Falkowski
2021-05-20 23:56 ` [PATCH 1/2] Makefile: clang-tools: Print information when clang-tidy tool is missing Nick Desaulniers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKwvOd=32_yNvAWRjyczOoEjsWje9SfaB=S1s9kS1bRFZhuU8g@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.falkowski9@gmail.com \
    --cc=masahiroy@kernel.org \
    --cc=natechancellor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.