Blame SOURCES/BZ-1967686-do-not-error-out-on-SIGINT.patch

bbd868
From 9147d3b66e0a263c2eb427b7892b34c925363854 Mon Sep 17 00:00:00 2001
bbd868
From: Michal Domonkos <mdomonko@redhat.com>
bbd868
Date: Thu, 17 Feb 2022 17:36:00 +0100
bbd868
Subject: [PATCH] Don't error out when command receives SIGINT
bbd868
bbd868
Interrupting a running command isn't really an execution problem so
bbd868
don't print an error or return a non-zero exit status.
bbd868
bbd868
This is also how it worked in versions older than 2.0.
bbd868
bbd868
Resolves: rhbz#1967686
bbd868
---
bbd868
 src/fallback.c | 3 +++
bbd868
 src/scllib.c   | 3 +++
bbd868
 2 files changed, 6 insertions(+)
bbd868
bbd868
diff --git a/src/fallback.c b/src/fallback.c
bbd868
index 4b9c8fd..c907a34 100644
bbd868
--- a/src/fallback.c
bbd868
+++ b/src/fallback.c
bbd868
@@ -6,6 +6,7 @@
bbd868
 #include <errno.h>
bbd868
 #include <sys/stat.h>
bbd868
 #include <dirent.h>
bbd868
+#include <signal.h>
bbd868
 
bbd868
 #include "scllib.h"
bbd868
 #include "sclmalloc.h"
bbd868
@@ -229,6 +230,8 @@ scl_rc fallback_run_command(char * const colnames[], const char *cmd, bool exec)
bbd868
         xasprintf(&bash_cmd, "/bin/bash %s", tmp);
bbd868
         status = system(bash_cmd);
bbd868
         if (status == -1 || !WIFEXITED(status)) {
bbd868
+            if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
bbd868
+                goto exit;
bbd868
             debug("Problem with executing command \"%s\"\n", bash_cmd);
bbd868
             ret = ERUN;
bbd868
             goto exit;
bbd868
diff --git a/src/scllib.c b/src/scllib.c
bbd868
index a182194..2ba8df8 100644
bbd868
--- a/src/scllib.c
bbd868
+++ b/src/scllib.c
bbd868
@@ -11,6 +11,7 @@
bbd868
 #include <rpm/rpmcli.h>
bbd868
 #include <errno.h>
bbd868
 #include <wordexp.h>
bbd868
+#include <signal.h>
bbd868
 
bbd868
 #include "config.h"
bbd868
 #include "errors.h"
bbd868
@@ -341,6 +342,8 @@ scl_rc run_command(char * const colnames[], const char *cmd, bool exec)
bbd868
 
bbd868
         status = system(cmd);
bbd868
         if (status == -1 || !WIFEXITED(status)) {
bbd868
+            if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
bbd868
+                goto exit;
bbd868
             debug("Problem with executing program \"%s\"\n", cmd);
bbd868
             ret = ERUN;
bbd868
             goto exit;
bbd868
-- 
bbd868
2.35.1
bbd868