#define LXC_LOG_TIME_SIZE ((INTTYPE_TO_STRLEN(uint64_t)) * 2)
int lxc_log_fd = -EBADF;
-static int syslog_enable = 0;
+static bool wants_syslog = false;
int lxc_quiet_specified;
int lxc_log_use_global_fd;
static int lxc_loglevel_specified;
__do_free char *msg = NULL;
const char *log_container_name;
- if (!syslog_enable)
+ if (!wants_syslog)
return 0;
log_container_name = lxc_log_get_container_name();
return 0;
}
-inline void lxc_log_enable_syslog(void)
+void lxc_log_syslog_enable(void)
{
- syslog_enable = 1;
+ wants_syslog = true;
+}
+
+void lxc_log_syslog_disable(void)
+{
+ wants_syslog = false;
}
/*
extern int lxc_log_fd;
extern int lxc_log_syslog(int facility);
-extern void lxc_log_enable_syslog(void);
+extern void lxc_log_syslog_enable(void);
+extern void lxc_log_syslog_disable(void);
extern int lxc_log_set_level(int *dest, int level);
extern int lxc_log_get_level(void);
extern bool lxc_log_has_valid_level(void);
if (conf && conf->close_all_fds)
closeall = true;
+ /*
+ * Disable syslog at this point to avoid the above logging
+ * function to open a new fd and make the check_inherited function
+ * enter an infinite loop.
+ */
+ lxc_log_syslog_disable();
+
restart:
dir = opendir("/proc/self/fd");
if (!dir)
#endif
if (closeall) {
- close(fd);
+ if (close(fd))
+ SYSINFO("Closed inherited fd %d", fd);
+ else
+ INFO("Closed inherited fd %d", fd);
closedir(dir);
- INFO("Closed inherited fd %d", fd);
goto restart;
}
WARN("Inherited fd %d", fd);
}
+ closedir(dir);
- /* Only enable syslog at this point to avoid the above logging function
- * to open a new fd and make the check_inherited function enter an
- * infinite loop.
+ /*
+ * Only enable syslog at this point to avoid the above logging
+ * function to open a new fd and make the check_inherited function
+ * enter an infinite loop.
*/
- lxc_log_enable_syslog();
+ lxc_log_syslog_enable();
- closedir(dir); /* cannot fail */
return 0;
}