diff options
| author | Petr Mladek <pmladek@suse.com> | 2022-12-08 11:46:56 +0100 |
|---|---|---|
| committer | Petr Mladek <pmladek@suse.com> | 2022-12-08 11:46:56 +0100 |
| commit | 6b2b0d839acaa84f05a77184370f793752e786e9 (patch) | |
| tree | d051c2ca80acc8a442277410d23a2053685f8a85 /scripts/Kbuild.include | |
| parent | 7365df19e8ff7a031e1557616fc0b3aa6d794d7e (diff) | |
| parent | 5074ffbec67ac592614901771d3a15e1198d759d (diff) | |
Merge branch 'rework/console-list-lock' into for-linus
Diffstat (limited to 'scripts/Kbuild.include')
| -rw-r--r-- | scripts/Kbuild.include | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index ece44b735061..2bc08ace38a3 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -100,8 +100,29 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ quiet_redirect := silent_redirect := exec >/dev/null; +# Delete the target on interruption +# +# GNU Make automatically deletes the target if it has already been changed by +# the interrupted recipe. So, you can safely stop the build by Ctrl-C (Make +# will delete incomplete targets), and resume it later. +# +# However, this does not work when the stderr is piped to another program, like +# $ make >&2 | tee log +# Make dies with SIGPIPE before cleaning the targets. +# +# To address it, we clean the target in signal traps. +# +# Make deletes the target when it catches SIGHUP, SIGINT, SIGQUIT, SIGTERM. +# So, we cover them, and also SIGPIPE just in case. +# +# Of course, this is unneeded for phony targets. +delete-on-interrupt = \ + $(if $(filter-out $(PHONY), $@), \ + $(foreach sig, HUP INT QUIT TERM PIPE, \ + trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);)) + # printing commands -cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(cmd_$(1)) +cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1)) ### # if_changed - execute command if any prerequisite is newer than |
