if (prefork.is_parent()) {
return prefork.parent_wait();
}
- global_init_postfork(g_ceph_context, 0);
+ global_init_postfork_start(g_ceph_context);
}
common_init_finish(g_ceph_context);
global_init_chdir(g_ceph_context);
derr << "done compacting" << dendl;
}
- if (g_conf->daemonize)
+ if (g_conf->daemonize) {
+ global_init_postfork_finish(g_ceph_context, 0);
prefork.daemonize();
+ }
messenger->start();
exit(1);
}
- global_init_postfork(cct, flags);
+ global_init_postfork_start(cct);
+ global_init_postfork_finish(cct, flags);
}
-void global_init_postfork(CephContext *cct, int flags)
+void global_init_postfork_start(CephContext *cct)
{
// restart log thread
g_ceph_context->_log->start();
<< err << dendl;
exit(1);
}
+
+ pidfile_write(g_conf);
+}
+
+void global_init_postfork_finish(CephContext *cct, int flags)
+{
+ /* We only close stderr once the caller decides the daemonization
+ * process is finished. This way we can allow error messages to be
+ * propagated in a manner that the user is able to see.
+ */
if (!(flags & CINIT_FLAG_NO_CLOSE_STDERR)) {
int ret = global_init_shutdown_stderr(cct);
if (ret) {
exit(1);
}
}
- pidfile_write(g_conf);
ldout(cct, 1) << "finished global_init_daemonize" << dendl;
}
+
void global_init_chdir(const CephContext *cct)
{
const md_config_t *conf = cct->_conf;
int global_init_prefork(CephContext *cct, int flags);
/*
- * perform all of the steps that global_init_daemonize performs just after
- * the fork.
+ * perform all the steps that global_init_daemonize performs just after
+ * the fork, except closing stderr, which we'll do later on.
*/
-void global_init_postfork(CephContext *cct, int flags);
+void global_init_postfork_start(CephContext *cct);
+
+/*
+ * close stderr, thus completing the postfork.
+ */
+void global_init_postfork_finish(CephContext *cct, int flags);
+
/*
* global_init_daemonize handles daemonizing a process.