git: 97b61b22edba - main - route: fix `route -n monitor` when its output is redirected

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Thu, 17 Jul 2025 17:17:15 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=97b61b22edba74c62adba1d022fb73541aa5ff93

commit 97b61b22edba74c62adba1d022fb73541aa5ff93
Author:     Oleg Streejak <oleg@pcbtech.ru>
AuthorDate: 2025-07-17 17:06:50 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-07-17 17:17:01 +0000

    route: fix `route -n monitor` when its output is redirected
    
    This is a small oversight in the transition to netlink; the non-netlink
    implementation would explicitly flush its stdout as necessary to avoid
    apparent long stalls in output when we end up fully-buffered.  Adjust
    the netlink implementation to do the same.  This was noticed while
    trying to triage failures in the wg-quick script.
    
    Commit message by kevans, patch by author.
    
    PR:             278265
    Fixes:          091fec1188929 ("route: switch transport protocol [...]")
    MFC after:      3 days
---
 sbin/route/route_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sbin/route/route_netlink.c b/sbin/route/route_netlink.c
index 631c2860b547..ba22a2ec1e22 100644
--- a/sbin/route/route_netlink.c
+++ b/sbin/route/route_netlink.c
@@ -738,6 +738,7 @@ print_nlmsg(struct nl_helper *h, struct nlmsghdr *hdr, struct snl_msg_info *cinf
 		print_nlmsg_generic(h, hdr, cinfo);
 	}
 
+	fflush(stdout);
 	snl_clear_lb(&h->ss_cmd);
 }