diff -u bwbar-1.2.3/bwbar.c bwbar-1.2.3.new/bwbar.c --- bwbar-1.2.3/bwbar.c 2006-08-26 18:31:26.000000000 +0200 +++ bwbar-1.2.3.new/bwbar.c 2008-09-01 11:30:41.000000000 +0200 @@ -156,6 +156,7 @@ { "kbps", 0, 0, 'k' }, { "Mbps", 0, 0, 'M' }, { "Gbps", 0, 0, 'G' }, + { "Daemon", 0, 0, 'D' }, { "help", 0, 0, 'h' }, { 0, 0, 0, 0 } }; @@ -178,6 +179,7 @@ " --kbps -k Bandwidth is measured in kbit/s\n" " --Mbps -M Bandwidth is measured in Mbit/s (default)\n" " --Gbps -G Bandwidth is measured in Gbit/s\n" + " --Daemon -D Run as daemon\n" " --help -h Display this text\n", program); exit(err); @@ -211,10 +213,11 @@ int width = 600; /* Bar width */ int height = 4; /* Bar height */ int border = 1; /* Bar border */ + int daemon_mode = 0; /* run as daemon */ program = argv[0]; - while ( (opt = getopt_long(argc, argv, "iof:p:t:x:y:b:kMGh", longopts, NULL)) != -1 ) { + while ( (opt = getopt_long(argc, argv, "iof:p:t:x:y:b:kMGhD", longopts, NULL)) != -1 ) { switch ( opt ) { case 'i': measure_input = 1; @@ -252,6 +255,9 @@ unit = 1.0e+9; unit_name = "Gbit/s"; break; + case 'D': + daemon_mode = 1; + break; case 'h': usage(0); break; @@ -279,6 +285,11 @@ first = 1; lbin = 0; lbout = 0; + if ( daemon_mode == 1) { + if ( fork() != 0) + return 0; + } + gettimeofday(&t_last, NULL); while ( 1 ) {