bin/151600: [patch] route(8) does not always flush stdout

Eric van Gyzen eric at vangyzen.net
Wed Oct 20 13:40:10 UTC 2010


>Number:         151600
>Category:       bin
>Synopsis:       [patch] route(8) does not always flush stdout
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 20 13:40:09 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Eric van Gyzen
>Release:        8.1-RELEASE
>Organization:
McAfee, Inc.
>Environment:
N/A
>Description:
The route(8) command does not flush stdout after printing a RTM_IFANNOUNCE message or a RTM_IFINFO message that has no addresses.  These flushes are critical for, say, writing a script that parses the output of "/sbin/route -n monitor" to act on changes in link status in a timely fashion.
>How-To-Repeat:
1. Run:
    /sbin/route -n monitor | cat
2. Plug/unplug some network cables.
3. Notice that the link status messages are not displayed.
4. In another terminal, run:
    /sbin/route -n get default
5. Notice that the link status messages are displayed immediately before the other messages.
>Fix:
diff -u -r1.93 route.c
--- route.c     27 Feb 2010 10:18:33 -0000      1.93
+++ route.c     20 Oct 2010 13:26:14 -0000
@@ -1395,6 +1395,7 @@
                        break;
                }
                printf("\n");
+               (void) fflush(stdout);
                break;

        default:
@@ -1517,6 +1518,7 @@

        if (addrs == 0) {
                (void) putchar('\n');
+               (void) fflush(stdout);
                return;
        }
        (void) printf("\nsockaddrs: ");


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list