syslogd: Only set debugging_on in Debug (-d) mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
b7d4225ef1
commit
8e255b7f9d
@ -221,7 +221,7 @@ int usage(int code)
|
|||||||
" :port The port is either a UDP port number, or a\n"
|
" :port The port is either a UDP port number, or a\n"
|
||||||
" service name, default is 'syslog', port 514.\n"
|
" service name, default is 'syslog', port 514.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -d Enable debug mode\n"
|
" -d Enable debug mode, implicitly enables -F to prevent backgrounding\n"
|
||||||
" -F Run in foreground, required when run from a modern init/supervisor\n"
|
" -F Run in foreground, required when run from a modern init/supervisor\n"
|
||||||
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
|
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
|
||||||
" -k Allow logging with facility 'kernel', otherwise remapped to 'user'.\n"
|
" -k Allow logging with facility 'kernel', otherwise remapped to 'user'.\n"
|
||||||
@ -297,6 +297,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'd': /* debug */
|
case 'd': /* debug */
|
||||||
Debug = 1;
|
Debug = 1;
|
||||||
|
Foreground = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F': /* don't fork */
|
case 'F': /* don't fork */
|
||||||
@ -387,10 +388,10 @@ int main(int argc, char *argv[])
|
|||||||
warn("Kernel logging disabled, failed opening %s", _PATH_KLOG);
|
warn("Kernel logging disabled, failed opening %s", _PATH_KLOG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((!Foreground) && (!Debug)) {
|
if (!Foreground) {
|
||||||
signal(SIGTERM, doexit);
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
|
signal(SIGTERM, doexit);
|
||||||
if (fork()) {
|
if (fork()) {
|
||||||
/*
|
/*
|
||||||
* Parent process
|
* Parent process
|
||||||
@ -411,7 +412,7 @@ int main(int argc, char *argv[])
|
|||||||
for (int i = 0; i < getdtablesize(); i++)
|
for (int i = 0; i < getdtablesize(); i++)
|
||||||
(void)close(i);
|
(void)close(i);
|
||||||
untty();
|
untty();
|
||||||
} else {
|
} else if (Debug) {
|
||||||
debugging_on = 1;
|
debugging_on = 1;
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
}
|
}
|
||||||
@ -2952,7 +2953,7 @@ static void logit(char *fmt, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!(Debug && debugging_on))
|
if (!debugging_on)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
Loading…
Reference in New Issue
Block a user