]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/global/global_init.cc
update sources to 12.2.7
[ceph.git] / ceph / src / global / global_init.cc
index 147f294a350ee775956f1de134634224f854526f..7d0abb622a372f7afa6548c80f247d25463f91d7 100644 (file)
@@ -414,13 +414,6 @@ void global_init_postfork_start(CephContext *cct)
         << err << dendl;
     exit(1);
   }
-  VOID_TEMP_FAILURE_RETRY(close(STDOUT_FILENO));
-  if (open("/dev/null", O_RDONLY) < 0) {
-    int err = errno;
-    derr << "global_init_daemonize: open(/dev/null) failed: error "
-        << err << dendl;
-    exit(1);
-  }
 
   const md_config_t *conf = cct->_conf;
   if (pidfile_write(conf) < 0)
@@ -435,8 +428,8 @@ void global_init_postfork_start(CephContext *cct)
 
 void global_init_postfork_finish(CephContext *cct)
 {
-  /* We only close stderr once the caller decides the daemonization
-   * process is finished.  This way we can allow error messages to be
+  /* We only close stdout+stderr once the caller decides the daemonization
+   * process is finished.  This way we can allow error or other messages to be
    * propagated in a manner that the user is able to see.
    */
   if (!(cct->get_init_flags() & CINIT_FLAG_NO_CLOSE_STDERR)) {
@@ -447,6 +440,15 @@ void global_init_postfork_finish(CephContext *cct)
       exit(1);
     }
   }
+
+  VOID_TEMP_FAILURE_RETRY(close(STDOUT_FILENO));
+  if (open("/dev/null", O_RDONLY) < 0) {
+    int err = errno;
+    derr << "global_init_daemonize: open(/dev/null) failed: error "
+        << err << dendl;
+    exit(1);
+  }
+
   ldout(cct, 1) << "finished global_init_daemonize" << dendl;
 }