Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH iproute2] devlink: Add fflush() in cmd_mon_show_cb()
@ 2020-08-20 13:51 Amit Cohen
  0 siblings, 0 replies; only message in thread
From: Amit Cohen @ 2020-08-20 13:51 UTC (permalink / raw)
  To: netdev; +Cc: stephen, dsahern, mlxsw, Amit Cohen, Ido Schimmel, Jiri Pirko

From: Amit Cohen <amcohen@nvidia.com>

Similar to other print functions we need to flush buffered data
in order to work with pipes and output redirects.

Without it, stdout output is buffered and not written to the disk.

This is useful when writing scripts that rely on devlink-monitor output.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 devlink/devlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 0ab0bca5..4b7d4452 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -4654,6 +4654,7 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
 		pr_out_trap_policer(dl, tb, false);
 		break;
 	}
+	fflush(stdout);
 	return MNL_CB_OK;
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-20 13:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 13:51 [PATCH iproute2] devlink: Add fflush() in cmd_mon_show_cb() Amit Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).