]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tree-wide: s/sigprocmask/pthread_sigmask()/g
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 24 May 2018 18:29:48 +0000 (20:29 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 24 May 2018 19:01:39 +0000 (21:01 +0200)
The behavior of sigprocmask() is unspecified in multi-threaded programs. Let's
use pthread_sigmask() instead.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cmd/lxc_init.c
src/lxc/cmd/lxc_monitord.c
src/lxc/start.c
src/lxc/terminal.c
src/lxc/utils.c

index c673bc60a6c8aada04f123c22959dbd0672073e0..2f03034512a2860bb26ffddd4080a9d533f5987e 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <libgen.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -266,7 +267,7 @@ int main(int argc, char *argv[])
        if (ret < 0)
                exit(EXIT_FAILURE);
 
-       ret = sigprocmask(SIG_SETMASK, &mask, &omask);
+       ret = pthread_sigmask(SIG_SETMASK, &mask, &omask);
        if (ret < 0)
                exit(EXIT_FAILURE);
 
@@ -340,7 +341,7 @@ int main(int argc, char *argv[])
                        }
                }
 
-               ret = sigprocmask(SIG_SETMASK, &omask, NULL);
+               ret = pthread_sigmask(SIG_SETMASK, &omask, NULL);
                if (ret < 0) {
                        SYSERROR("Failed to set signal mask");
                        exit(EXIT_FAILURE);
@@ -368,7 +369,7 @@ int main(int argc, char *argv[])
        if (ret < 0)
                exit(EXIT_FAILURE);
 
-       ret = sigprocmask(SIG_SETMASK, &omask, NULL);
+       ret = pthread_sigmask(SIG_SETMASK, &omask, NULL);
        if (ret < 0) {
                SYSERROR("Failed to set signal mask");
                exit(EXIT_FAILURE);
index 99f2bdb8b869a012018216c9e44c3385f2344bff..3b17b67d446e27ee364d355b569dec581d2cddae 100644 (file)
@@ -24,6 +24,7 @@
 #define _GNU_SOURCE
 #include <errno.h>
 #include <fcntl.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -386,7 +387,7 @@ int main(int argc, char *argv[])
            sigdelset(&mask, SIGSEGV) ||
            sigdelset(&mask, SIGBUS)  ||
            sigdelset(&mask, SIGTERM) ||
-           sigprocmask(SIG_BLOCK, &mask, NULL)) {
+           pthread_sigmask(SIG_BLOCK, &mask, NULL)) {
                SYSERROR("Failed to set signal mask.");
                exit(EXIT_FAILURE);
        }
index f4f8e520c2d45a511e224e16f36dd3e1cf533e56..ba737d23911873401180b21a666986dfbe7ae0ea 100644 (file)
@@ -32,6 +32,7 @@
 #include <fcntl.h>
 #include <grp.h>
 #include <poll.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -314,7 +315,7 @@ static int setup_signal_fd(sigset_t *oldmask)
                        return -EBADF;
        }
 
-       ret = sigprocmask(SIG_BLOCK, &mask, oldmask);
+       ret = pthread_sigmask(SIG_BLOCK, &mask, oldmask);
        if (ret < 0) {
                SYSERROR("Failed to set signal mask");
                return -EBADF;
@@ -860,7 +861,7 @@ int lxc_init(const char *name, struct lxc_handler *handler)
        return 0;
 
 out_restore_sigmask:
-       sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
+       pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
 out_delete_tty:
        lxc_delete_tty(&conf->ttys);
 out_aborting:
@@ -986,7 +987,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
        }
 
        /* Reset mask set by setup_signal_fd. */
-       ret = sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
+       ret = pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
        if (ret < 0)
                WARN("%s - Failed to restore signal mask", strerror(errno));
 
@@ -1064,7 +1065,7 @@ static int do_start(void *data)
                goto out_warn_father;
        }
 
-       ret = sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
+       ret = pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
        if (ret < 0) {
                SYSERROR("Failed to set signal mask");
                goto out_warn_father;
index 7d69a67e2f5bce9f39773ef5c8e1e46ee651fd53..234ad672e5c25ab5a27f574b24f3b27d3e8ec24e 100644 (file)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <lxc/lxccontainer.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -172,7 +173,7 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
                goto on_error;
        }
 
-       ret = sigprocmask(SIG_BLOCK, &mask, &ts->oldmask);
+       ret = pthread_sigmask(SIG_BLOCK, &mask, &ts->oldmask);
        if (ret < 0) {
                WARN("Failed to block signals");
                goto on_error;
@@ -181,7 +182,7 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
        ts->sigfd = signalfd(-1, &mask, SFD_CLOEXEC);
        if (ts->sigfd < 0) {
                WARN("Failed to create signal fd");
-               sigprocmask(SIG_SETMASK, &ts->oldmask, NULL);
+               (void)pthread_sigmask(SIG_SETMASK, &ts->oldmask, NULL);
                goto on_error;
        }
 
@@ -206,7 +207,7 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
        if (ts->sigfd >= 0) {
                close(ts->sigfd);
 
-               if (sigprocmask(SIG_SETMASK, &ts->oldmask, NULL) < 0)
+               if (pthread_sigmask(SIG_SETMASK, &ts->oldmask, NULL) < 0)
                        WARN("%s - Failed to restore signal mask", strerror(errno));
        }
 
index 2669a4d4beff218a4e02d3e15f980f3b00fdedd9..82403dfc69ea38dbf83fb0582c226cab4d26b9f0 100644 (file)
@@ -31,6 +31,7 @@
 #include <grp.h>
 #include <inttypes.h>
 #include <libgen.h>
+#include <pthread.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -495,7 +496,7 @@ struct lxc_popen_FILE *lxc_popen(const char *command)
                if (ret < 0)
                        _exit(EXIT_FAILURE);
 
-               ret = sigprocmask(SIG_UNBLOCK, &mask, NULL);
+               ret = pthread_sigmask(SIG_UNBLOCK, &mask, NULL);
                if (ret < 0)
                        _exit(EXIT_FAILURE);