]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: port over to pop_pending_signal() 20168/head
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Jul 2021 08:38:09 +0000 (10:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jul 2021 08:38:09 +0000 (10:38 +0200)
src/shared/copy.c

index 04f99a2d6f8fcf434d67016e9c4ae987ef15a222..65d75a15d54a514355d6220b65e4e49c71bd6aff 100644 (file)
@@ -24,6 +24,7 @@
 #include "nulstr-util.h"
 #include "rm-rf.h"
 #include "selinux-util.h"
+#include "signal-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
@@ -87,22 +88,6 @@ static int fd_is_nonblock_pipe(int fd) {
         return FLAGS_SET(flags, O_NONBLOCK) ? FD_IS_NONBLOCKING_PIPE : FD_IS_BLOCKING_PIPE;
 }
 
-static int sigint_pending(void) {
-        sigset_t ss;
-
-        assert_se(sigemptyset(&ss) >= 0);
-        assert_se(sigaddset(&ss, SIGINT) >= 0);
-
-        if (sigtimedwait(&ss, NULL, &(struct timespec) { 0, 0 }) < 0) {
-                if (errno == EAGAIN)
-                        return false;
-
-                return -errno;
-        }
-
-        return true;
-}
-
 int copy_bytes_full(
                 int fdf, int fdt,
                 uint64_t max_bytes,
@@ -192,7 +177,7 @@ int copy_bytes_full(
                         return 1; /* return > 0 if we hit the max_bytes limit */
 
                 if (FLAGS_SET(copy_flags, COPY_SIGINT)) {
-                        r = sigint_pending();
+                        r = pop_pending_signal(SIGINT);
                         if (r < 0)
                                 return r;
                         if (r > 0)
@@ -861,7 +846,7 @@ static int fd_copy_directory(
                         continue;
 
                 if (FLAGS_SET(copy_flags, COPY_SIGINT)) {
-                        r = sigint_pending();
+                        r = pop_pending_signal(SIGINT);
                         if (r < 0)
                                 return r;
                         if (r > 0)