--- bwbar.c.orig 2004-07-16 15:05:08.000000000 +0200 +++ bwbar.c 2004-07-16 15:11:03.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; @@ -278,7 +284,12 @@ first = 1; lbin = 0; lbout = 0; - + + if ( daemon_mode == 1) { + if ( fork() != 0) + return 0; + } + while ( 1 ) { /**** Begin code that obtains bandwidth data ****/