Fix for Feature Request from ssb
authorBernd Eckenfels <net-tools@lina.inka.de>
Thu, 27 Aug 2009 20:29:19 +0000 (20:29 +0000)
committerBernd Eckenfels <net-tools@lina.inka.de>
Thu, 27 Aug 2009 20:29:19 +0000 (20:29 +0000)
[ Feature Request #4466 ] --continuous should flush stdout

netstat.c

index c50c58f..053d713 100644 (file)
--- a/netstat.c
+++ b/netstat.c
@@ -6,7 +6,7 @@
  *              NET-3 Networking Distribution for the LINUX operating
  *              system.
  *
- * Version:     $Id: netstat.c,v 1.64 2009/07/28 01:40:17 ecki Exp $
+ * Version:     $Id: netstat.c,v 1.65 2009/08/27 20:29:19 ecki Exp $
  *
  * Authors:     Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
  *              Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
@@ -299,6 +299,12 @@ static void prg_cache_clear(void)
     prg_cache_loaded=0;
 }
 
+static void wait_continous(void)
+{
+    fflush(stdout);
+    sleep(1);
+}
+
 static int extract_type_1_socket_inode(const char lname[], unsigned long * inode_p) {
 
     /* If lname is of the form "socket:[12345]", extract the "12345"
@@ -1725,7 +1731,7 @@ int main
                             flag_not & FLAG_NUM_PORT, flag_exp);
            if (i || !flag_cnt)
                break;
-           sleep(1);
+           wait_continous();
        }
 #else
        ENOSUPP("netstat", "FW_MASQUERADE");
@@ -1778,7 +1784,7 @@ int main
            i = route_info(afname, options);
            if (i || !flag_cnt)
                break;
-           sleep(1);
+            wait_continous();
        }
        return (i);
     }
@@ -1787,7 +1793,7 @@ int main
            i = iface_info();
            if (!flag_cnt || i)
                break;
-           sleep(1);
+            wait_continous();
        }
        return (i);
     }
@@ -1934,7 +1940,7 @@ int main
                    
        if (!flag_cnt || i)
            break;
-       sleep(1);
+        wait_continous();
        prg_cache_clear();
     }
     return (i);