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