vis: Convert to procd based init script
[feed/routing.git] / vis / patches / 0001-Allow-one-to-disable-forking-to-background-in-debug_.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sun, 1 Dec 2013 14:39:00 +0100
3 Subject: Allow one to disable forking to background in debug_mode 0
4
5 ---
6 posix/init.c | 19 ++++++++++++++-----
7 1 file changed, 14 insertions(+), 5 deletions(-)
8
9 --- a/vis.c
10 +++ b/vis.c
11 @@ -58,6 +58,7 @@ buffer_t *fillme = NULL;
12
13 static int8_t stop;
14 uint8_t debug_level = 0;
15 +static int no_detach = 0;
16
17 formats selected_formats = dot_draw;
18
19 @@ -716,6 +717,7 @@ void print_usage() {
20 printf( "Usage: vis <interface(s)> \n" );
21 printf( "\t-j output mesh topology as json on port %d\n", JSON_PORT );
22 printf( "\t-d debug level\n" );
23 + printf( "\t-D run in foreground\n" );
24 printf( "\t-h help\n" );
25 printf( "\t-v Version\n\n" );
26 printf( "Olsrs3d / Meshs3d is an application to visualize a mesh network.\nIt is a part of s3d, have a look at s3d.berlios.de\n\n" );
27 @@ -736,7 +738,7 @@ int main( int argc, char **argv ) {
28 fd_set wait_sockets, tmp_wait_sockets;
29
30
31 - while ( ( optchar = getopt ( argc, argv, "jd:hv" ) ) != -1 ) {
32 + while ( ( optchar = getopt ( argc, argv, "jd:hvD" ) ) != -1 ) {
33
34 switch( optchar ) {
35
36 @@ -771,6 +773,11 @@ int main( int argc, char **argv ) {
37 selected_formats |= json;
38 found_args++;
39 break;
40 +
41 + case 'D':
42 + no_detach = 1;
43 + found_args++;
44 + break;
45
46 default:
47 print_usage();
48 @@ -889,7 +896,7 @@ int main( int argc, char **argv ) {
49
50
51 /* daemonize */
52 - if ( debug_level == 0 ) {
53 + if ( debug_level == 0 && !no_detach) {
54
55 if ( my_daemon() < 0 )
56 exit_error( "Error - can't fork to background: %s\n", strerror(errno) );