Repository : ssh://git@diktynna/batmand
On branch : main
>---------------------------------------------------------------
commit 2f62b17d4132f82c4716b672101eb7faa916192a
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sun Dec 1 14:39:00 2013 +0100
Allow one to disable forking to background in debug_mode 0
>---------------------------------------------------------------
2f62b17d4132f82c4716b672101eb7faa916192a
batman.c | 1 +
man/batmand.8 | 3 +++
posix/init.c | 13 +++++++++----
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/batman.c b/batman.c
index c3dfa7f..1c21fa8 100644
--- a/batman.c
+++ b/batman.c
@@ -145,6 +145,7 @@ void usage(void)
fprintf( stderr, " -v print version\n" );
fprintf( stderr, " --policy-routing-script\n" );
fprintf( stderr, " --disable-client-nat\n" );
+ fprintf( stderr, " --no-detach\n" );
}
diff --git a/man/batmand.8 b/man/batmand.8
index 89fcde5..38956ef 100644
--- a/man/batmand.8
+++ b/man/batmand.8
@@ -123,6 +123,9 @@ Since no topology database is computed by the protocol an additional solution to
.B \-\-disable\-client\-nat
Since version 0.3.2 batmand uses iptables to set the NAT rules on the gateX interface of the batman client (\-r XX). That option disables this feature of batmand and switches the internet tunnel mode to "half tunnels" (the packets towards the gateway are tunneled but not the packets that are coming back) unless NAT was enabled manually. Be sure to know what you are doing! Without NAT the gateway needs to have a route to the client or the packets will be dropped silently.
.TP
+.B \-\-no\-detach
+Run batmand in foreground
+.TP
.B \-\-policy\-routing\-script
This option disables the policy routing feature of batmand \(hy all routing changes are send to the script which can make use of this information or not. Firmware and package maintainers can use this option to tightly integrate batmand into their own routing policies. This option is only available in daemon mode.
.SH EXAMPLES
diff --git a/posix/init.c b/posix/init.c
index cb710f2..4533cdc 100644
--- a/posix/init.c
+++ b/posix/init.c
@@ -51,6 +51,7 @@
#include "../types.h"
int8_t stop;
+int no_detach;
static void create_routing_pipe(void)
@@ -124,6 +125,7 @@ void apply_init_args( int argc, char *argv[] ) {
{"purge-timeout", required_argument, 0, 'q'},
{"disable-aggregation", no_argument, 0, 'x'},
{"disable-client-nat", no_argument, 0, 'z'},
+ {"no-detach", no_argument, 0, 'D'},
{0, 0, 0, 0}
};
@@ -131,7 +133,7 @@ void apply_init_args( int argc, char *argv[] ) {
stop = 0;
prog_name = argv[0];
- while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vV", long_options, &option_index ) ) != -1 ) {
+ while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vVD", long_options, &option_index ) ) != -1 ) {
switch ( optchar ) {
@@ -343,6 +345,11 @@ void apply_init_args( int argc, char *argv[] ) {
found_args++;
break;
+ case 'D':
+ no_detach = 1;
+ found_args++;
+ break;
+
case 'h':
default:
usage();
@@ -501,12 +508,10 @@ void apply_init_args( int argc, char *argv[] ) {
/* daemonize */
if (debug_level == 0) {
- if (daemon(0, 0) < 0) {
-
+ if (!no_detach && daemon(0, 0) < 0) {
printf("Error - can't fork to background: %s\n", strerror(errno));
restore_defaults();
exit(EXIT_FAILURE);
-
}
openlog("batmand", LOG_PID, LOG_DAEMON);