]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: add lxc_set_death_signal()
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 19 Feb 2018 09:58:56 +0000 (10:58 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 19 Feb 2018 09:58:56 +0000 (10:58 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c
src/lxc/utils.c
src/lxc/utils.h

index e664087c2d7bcd7797e1641c1a0d138dccea0773..db961e5698aa7996d1a786f220132e985f5fe9fe 100644 (file)
@@ -996,32 +996,6 @@ void lxc_abort(const char *name, struct lxc_handler *handler)
        }
 }
 
-static int lxc_set_death_signal(int signal)
-{
-       int ret;
-       pid_t ppid;
-
-       ret = prctl(PR_SET_PDEATHSIG, signal, 0, 0, 0);
-
-       /* Check whether we have been orphaned. */
-       ppid = (pid_t)syscall(SYS_getppid);
-       if (ppid == 1) {
-               pid_t self;
-
-               self = lxc_raw_getpid();
-               ret = kill(self, SIGKILL);
-               if (ret < 0)
-                       return -1;
-       }
-
-       if (ret < 0) {
-               SYSERROR("Failed to set PR_SET_PDEATHSIG to %d", signal);
-               return -1;
-       }
-
-       return 0;
-}
-
 static int do_start(void *data)
 {
        int ret;
index afcbdf34a51e0a4adf3157d781fd3f2acf2ec9fd..d7527b42947a38b9a3f2f84de8d012a216089d63 100644 (file)
@@ -2510,3 +2510,29 @@ uint64_t lxc_find_next_power2(uint64_t n)
        n = n << 1;
        return n;
 }
+
+int lxc_set_death_signal(int signal)
+{
+       int ret;
+       pid_t ppid;
+
+       ret = prctl(PR_SET_PDEATHSIG, signal, 0, 0, 0);
+
+       /* Check whether we have been orphaned. */
+       ppid = (pid_t)syscall(SYS_getppid);
+       if (ppid == 1) {
+               pid_t self;
+
+               self = lxc_raw_getpid();
+               ret = kill(self, SIGKILL);
+               if (ret < 0)
+                       return -1;
+       }
+
+       if (ret < 0) {
+               SYSERROR("Failed to set PR_SET_PDEATHSIG to %d", signal);
+               return -1;
+       }
+
+       return 0;
+}
index 048995475603ec6d674c9c22cdd930c16e972e61..224c7a7244492b143db20325ff51882e82fbc7ea 100644 (file)
@@ -589,4 +589,7 @@ static inline pid_t lxc_raw_gettid(void)
 #endif
 }
 
+/* Set a signal the child process will receive after the parent has died. */
+extern int lxc_set_death_signal(int signal);
+
 #endif /* __LXC_UTILS_H */