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