pid_t SID;
int r;
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
log_notice("Double forking elogind");
log_notice("Parent PID : %5d", getpid_cached());
log_notice("Parent SID : %5d", getsid(getpid_cached()));
if (r)
return child;
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
log_notice("Child PID : %5d", getpid_cached());
log_notice("Child SID : %5d", getsid(getpid_cached()));
#endif // ENABLE_DEBUG_ELOGIND
if ((pid_t)-1 == SID)
return log_error_errno(errno, "Failed to create new SID: %m");
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
log_notice("Child new SID : %5d", getsid(getpid_cached()));
#endif // ENABLE_DEBUG_ELOGIND
umask(0022);
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
log_notice("Grand child PID: %5d", getpid_cached());
log_notice("Grand child SID: %5d", getsid(getpid_cached()));
#endif // ENABLE_DEBUG_ELOGIND
/* Note: At this point, the logging is not initialized, so we can not
use log_debug_elogind(). */
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
log_notice("elogind startup: Daemonize: %s, Show Help: %s, Wrong arg: %s",
daemonize ? "True" : "False",
show_help ? "True" : "False",
m->test_run_flags = 0;
/* Init sleep modes and states */
- m->suspend_mode = NULL;
- m->suspend_state = NULL;
- m->hibernate_mode = NULL;
- m->hibernate_state = NULL;
- m->hybrid_sleep_mode = NULL;
- m->hybrid_sleep_state = NULL;
+ m->suspend_mode = NULL;
+ m->suspend_state = NULL;
+ m->hibernate_mode = NULL;
+ m->hibernate_state = NULL;
+ m->hybrid_sleep_mode = NULL;
+ m->hybrid_sleep_state = NULL;
+ m->hibernate_delay_sec = 0;
/* If elogind should be its own controller, mount its cgroup */
if (streq(SYSTEMD_CGROUP_CONTROLLER, "_elogind")) {
/// Add-On for manager_reset_config()
void elogind_manager_reset_config(Manager* m) {
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
int dbg_cnt;
#endif // ENABLE_DEBUG_ELOGIND
m->hybrid_sleep_mode = strv_new("suspend", "platform", "shutdown", NULL);
if (!m->hybrid_sleep_state)
m->hybrid_sleep_state = strv_new("disk", NULL);
+ if (!m->hibernate_delay_sec)
+ m->hibernate_delay_sec = 180 * USEC_PER_MINUTE;
-#ifdef ENABLE_DEBUG_ELOGIND
+#if ENABLE_DEBUG_ELOGIND
dbg_cnt = -1;
while (m->suspend_mode && m->suspend_mode[++dbg_cnt])
log_debug_elogind("suspend_mode[%d] = %s",
while (m->hybrid_sleep_state[++dbg_cnt])
log_debug_elogind("hybrid_sleep_state[%d] = %s",
dbg_cnt, m->hybrid_sleep_state[dbg_cnt]);
+ log_debug_elogind("hibernate_delay_sec: %ul seconds (%ul minutes)",
+ m->hibernate_delay_sec / USEC_PER_SEC,
+ m->hibernate_delay_sec / USEC_PER_MINUTE);
#endif // ENABLE_DEBUG_ELOGIND
}