troglobit / mini-snmpd

A minimal SNMP agent implementation
https://troglobit.com/projects/mini-snmpd/
GNU General Public License v2.0
69 stars 36 forks source link

mini-snmpd not running in terminal #10

Closed jdamme closed 7 years ago

jdamme commented 7 years ago

Hi

"The program does not put itself into the background or detach itself from the controlling terminal. This is not included on purpose since normally the program is started from the init process, where running in background is not desired."

I run the executable and it is running in the background. I tried a snmpwalk and it worked. But the only way to kill it, is with the pid.

OS : ubuntu:16.04

How to reproduce: I cloned the project and configured it:

$ ./autogen.sh ./autogen.sh autoreconf: Entering directory .' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force --warnings=portability autoreconf: configure.ac: tracing autoreconf: configure.ac: not using Libtool autoreconf: running: /usr/bin/autoconf --force --warnings=portability autoreconf: running: /usr/bin/autoheader --force --warnings=portability autoreconf: running: automake --add-missing --force-missing --warnings=portability configure.ac:9: installing './compile' configure.ac:2: installing './install-sh' configure.ac:2: installing './missing' Makefile.am: installing './depcomp' autoreconf: no config.status: cannot re-make autoreconf: Leaving directory.

$ ./configure $ make $ ./mini_snmpd -i enp0s31f6,wlp1s0 --->Running in the background

I tried it another way: $ autoreconf -i configure.ac:9: installing './compile' configure.ac:2: installing './install-sh' configure.ac:2: installing './missing' Makefile.am: installing './depcomp'

$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for unistd.h... (cached) yes checking for stdint.h... (cached) yes checking for stdlib.h... (cached) yes checking syslog.h usability... yes checking syslog.h presence... yes checking for syslog.h... yes checking signal.h usability... yes checking signal.h presence... yes checking for signal.h... yes checking getopt.h usability... yes checking getopt.h presence... yes checking for getopt.h... yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking sys/socket.h usability... yes checking sys/socket.h presence... yes checking for sys/socket.h... yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking for sys/types.h... (cached) yes checking net/if.h usability... yes checking net/if.h presence... yes checking for net/if.h... yes checking netinet/in.h usability... yes checking netinet/in.h presence... yes checking for netinet/in.h... yes checking for strstr... yes checking for strtod... yes checking for strtoul... yes checking for strtok... yes checking for getopt... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating config.h config.status: executing depfiles commands

$ make make all-am make[1]: Entering directory '/home/jova/Libs/SNMP/mini-snmpd' CC mini_snmpd.o CC linux.o CC freebsd.o CC mib.o CC globals.o CC protocol.o CC utils.o CCLD mini_snmpd

$ ./mini_snmpd -i enp0s31f6,wlp1s0 --->Also running in the background

troglobit commented 7 years ago

Thanks, seems I've not updated the man page properly after all the refactoring.

The "new" default behavior is std UNIX daemon style, and then use -n to run in foreground:

-n, --foreground       Run in foreground, do not detach from controlling terminal

I'll update the man page.