Re: [PATCH 23/48] klp-build: Fix patch cleanup on interrupt
From: Song Liu
Date: Fri Apr 24 2026 - 17:56:46 EST
On Wed, Apr 22, 2026 at 9:04 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> If a build error occurs and the user hits Ctrl-C while a large patch is
> being reverted during cleanup, the cleanup EXIT trap gets re-triggered
> and tries to re-revert the already partially-reverted patch. That
> causes 'patch -R' to repeatedly prompt
>
> "Unreversed patch detected! Ignore -R? [n]"
>
> for each already-reverted hunk, with no way to break out.
>
> Fix it by adding '--force' to the patch revert command in
> revert_patch(), which causes it to silently ignore already-reverted
> hunks. And ignore errors, as the cleanup is always best-effort.
>
> For similar reasons, add to APPLIED_PATCHES before (rather than after)
> applying the patch in apply_patch() so an interrupted apply will also
> get cleaned up.
>
> Fixes: d36a7343f4ba ("livepatch/klp-build: switch to GNU patch and recountdiff")
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Acked-by: Song Liu <song@xxxxxxxxxx>