]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/Preforker.h
import 15.2.5
[ceph.git] / ceph / src / common / Preforker.h
index 5951fbeb46a1926d664c7661d835033f871bcbf7..d34179b40204a71099933702b8dbe9aaeb8908d2 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef CEPH_COMMON_PREFORKER_H
 #define CEPH_COMMON_PREFORKER_H
 
+#include <signal.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -45,6 +46,17 @@ public:
       return (errno = e, -1);
     }
 
+    struct sigaction sa;
+    sa.sa_handler = SIG_IGN;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = 0;
+    if (sigaction(SIGHUP, &sa, nullptr) != 0) {
+      int e = errno;
+      oss << "[" << getpid() << "]: unable to ignore SIGHUP: " << cpp_strerror(e);
+      err = oss.str();
+      return (errno = e, -1);
+    }
+
     forked = true;
 
     childpid = fork();