log.c: New log_exit() function, called at shutdown

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-07-02 12:31:38 +02:00
1 parent 8ce330bcdb
commit 1036c365b8
4 files changed
+21 -15

No files matched your search

+13
View File
@@ -22,6 +22,7 @@
*/
#include "config.h"
#include <sched.h> /* sched_yield() */
#include <stdio.h>
#include <stdarg.h>
#include <lite/lite.h>
@@ -31,6 +32,18 @@
static int loglevel = LOG_NOTICE;
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
void log_exit(void)
{
if (quiet) {
silent = SILENT_MODE;
if (!silent) {
sched_yield();
fputs("\n", stderr);
}
}
}
void log_debug(void)
{
debug = !debug;
+2
View File
@@ -40,6 +40,8 @@
#define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt "\n", __func__, ##args)
#define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %m\n", __func__, ##args)
void log_exit (void);
void log_debug (void);
void logit (int prio, const char *fmt, ...);
-15
View File
@@ -25,7 +25,6 @@
#include "config.h" /* Generated by configure script */
#include <ctype.h> /* isblank() */
#include <sched.h>
#include <string.h>
#include <sys/wait.h>
#include <net/if.h>
@@ -468,20 +467,6 @@ void service_reload_dynamic(void)
*/
void service_runlevel(int newlevel)
{
if (newlevel == 0 || newlevel == 6) {
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
if (quiet) {
silent = SILENT_MODE;
if (!silent) {
sched_yield();
fputs("\n", stderr);
}
}
/* Call all shutdown hooks before rebooting... */
plugin_run_hooks(HOOK_SHUTDOWN);
}
sm_set_runlevel(&sm, newlevel);
sm_step(&sm);
}
+6
View File
@@ -125,6 +125,12 @@ restart:
runlevel = sm->newlevel;
sm->newlevel = -1;
/* Restore terse mode and run hooks before shutdown */
if (runlevel == 0 || runlevel == 6) {
log_exit();
plugin_run_hooks(HOOK_SHUTDOWN);
}
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
runlevel_set(prevlevel, runlevel);