diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c --- a/contrib/bsnmp/snmpd/main.c +++ b/contrib/bsnmp/snmpd/main.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1509,7 +1510,7 @@ { int opt; FILE *fp; - int background = 1; + bool background = true; struct tport *p; const char *prefix = "snmpd"; struct lmodule *m; @@ -1526,11 +1527,6 @@ NULL }; - snmp_printf = snmp_printf_func; - snmp_error = snmp_error_func; - snmp_debug = snmp_debug_func; - asn_error = asn_error_func; - while ((opt = getopt(argc, argv, "c:dD:e:hI:l:m:p:")) != EOF) switch (opt) { @@ -1539,7 +1535,7 @@ break; case 'd': - background = 0; + background = false; break; case 'D': @@ -1601,6 +1597,13 @@ break; } + if (background) { + snmp_printf = snmp_printf_func; + snmp_error = snmp_error_func; + snmp_debug = snmp_debug_func; + asn_error = asn_error_func; + } + openlog(prefix, LOG_PID | (background ? 0 : LOG_PERROR), LOG_USER); setlogmask(LOG_UPTO(debug.logpri - 1));