mirror of
https://github.com/troglobit/finit.git
synced 2026-11-24 20:21:44 +00:00
log.c: New log_exit() function, called at shutdown
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
8ce330bcdb
commit
1036c365b8
4 files changed
+21
-15
No files matched your search
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <sched.h> /* sched_yield() */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
@@ -31,6 +32,18 @@
|
|||||||
|
|
||||||
static int loglevel = LOG_NOTICE;
|
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)
|
void log_debug(void)
|
||||||
{
|
{
|
||||||
debug = !debug;
|
debug = !debug;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
#define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt "\n", __func__, ##args)
|
#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)
|
#define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %m\n", __func__, ##args)
|
||||||
|
|
||||||
|
void log_exit (void);
|
||||||
|
|
||||||
void log_debug (void);
|
void log_debug (void);
|
||||||
void logit (int prio, const char *fmt, ...);
|
void logit (int prio, const char *fmt, ...);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include "config.h" /* Generated by configure script */
|
#include "config.h" /* Generated by configure script */
|
||||||
|
|
||||||
#include <ctype.h> /* isblank() */
|
#include <ctype.h> /* isblank() */
|
||||||
#include <sched.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@@ -468,20 +467,6 @@ void service_reload_dynamic(void)
|
|||||||
*/
|
*/
|
||||||
void service_runlevel(int newlevel)
|
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_set_runlevel(&sm, newlevel);
|
||||||
sm_step(&sm);
|
sm_step(&sm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,12 @@ restart:
|
|||||||
runlevel = sm->newlevel;
|
runlevel = sm->newlevel;
|
||||||
sm->newlevel = -1;
|
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);
|
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
|
||||||
runlevel_set(prevlevel, runlevel);
|
runlevel_set(prevlevel, runlevel);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user