@@ -138,6 +138,7 @@ void usage(void)
fprintf( stderr, " -b run connection in batch mode\n" );
fprintf( stderr, " -c connect via unix socket\n" );
fprintf( stderr, " -d debug level\n" );
+ fprintf( stderr, " -B don't run daemon in the background\n" );
fprintf( stderr, " -g gateway class\n" );
fprintf( stderr, " -h this help\n" );
fprintf( stderr, " -H verbose help\n" );
@@ -168,6 +169,7 @@ void verbose_usage(void)
fprintf( stderr, " 2 -> list gateways\n" );
fprintf( stderr, " 3 -> observe batman\n" );
fprintf( stderr, " 4 -> observe batman (very verbose)\n\n" );
+ fprintf( stderr, " -D not detach and doesn't run as daemon in the background\n" );
if ( debug_level_max == 5 )
fprintf( stderr, " 5 -> memory debug / cpu usage\n\n" );
@@ -61,6 +61,9 @@ allowed values: 1 -> list neighbors
Note that debug level 5 can be disabled at compile time.
.RE
.TP
+.B \-D don't run daemon in the background
+When this option is specified, batmand will not detach and does not become a daemon.
+.TP
.B \-g gateway class
The gateway class is used to tell other nodes in the network your available internet bandwidth. Just enter any number (optionally followed by "kbit" or "mbit") and the daemon will guess your appropriate gateway class. Use "/" to seperate the down- and upload rates. You can omit the upload rate and batmand will assume an upload of download / 5.
.RS 17
@@ -229,7 +229,7 @@ void apply_init_args( int argc, char *argv[] ) {
struct debug_level_info *debug_level_info;
struct list_head *list_pos, *list_pos_tmp;
uint8_t found_args = 1, batch_mode = 0, info_output = 0, was_hna = 0;
- int8_t res;
+ int8_t res, no_detach = 0;
int32_t optchar, option_index, recv_buff_len, bytes_written, download_speed = 0, upload_speed = 0;
char str1[16], str2[16], *slash_ptr, *unix_buff, *buff_ptr, *cr_ptr;
@@ -253,7 +253,7 @@ void apply_init_args( int argc, char *argv[] ) {
if ( strstr( SOURCE_VERSION, "-" ) != NULL )
printf( "WARNING: You are using the unstable batman branch. If you are interested in *using* batman get the latest stable release !\n" );
- 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:DhHio:g:p:r:s:vV", long_options, &option_index ) ) != -1 ) {
switch ( optchar ) {
@@ -306,6 +306,11 @@ void apply_init_args( int argc, char *argv[] ) {
found_args += ((*((char*)( optarg - 1)) == optchar) ? 1 : 2);
break;
+ case 'D':
+ no_detach++;
+ found_args++;
+ break;
+
case 'g':
if ( ( slash_ptr = strchr( optarg, '/' ) ) != NULL )
@@ -647,7 +652,7 @@ void apply_init_args( int argc, char *argv[] ) {
/* daemonize */
if (debug_level == 0) {
- if (my_daemon() < 0) {
+ if (no_detach == 0 && my_daemon() < 0) {
printf("Error - can't fork to background: %s\n", strerror(errno));
restore_defaults();