Skip to contentSkip to conversation

devlink: Add fflush() in cmd_mon_show_cb()

PATCH New Amit Cohen 1 participant 1 message Aug 20, 2020

Subsystems (2)
lore
Share & tools
lore

Amit Cohen

author
#0 lore raw

PATCH 1/1 devlink: Add fflush() in cmd_mon_show_cb()

From: Amit Cohen <[email protected]>

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.

---
 devlink/devlink.c | 1 +
 1 file changed, 1 insertion(+)
devlink/devlink.c +1 -0
index 0ab0bca5..4b7d4452 100644
@@ -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;
 }
 
Signature · 1 line
2.20.1