git: f50d2fced24f - main - Give usbdump a '-u' option for unbuffered output.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Oct 2024 11:21:27 UTC
The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=f50d2fced24f4dbffc1cc414da48ea7ef7b84d1e commit f50d2fced24f4dbffc1cc414da48ea7ef7b84d1e Author: Poul-Henning Kamp <phk@FreeBSD.org> AuthorDate: 2024-10-21 11:21:05 +0000 Commit: Poul-Henning Kamp <phk@FreeBSD.org> CommitDate: 2024-10-21 11:21:05 +0000 Give usbdump a '-u' option for unbuffered output. --- usr.sbin/usbdump/usbdump.8 | 3 +++ usr.sbin/usbdump/usbdump.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.sbin/usbdump/usbdump.8 b/usr.sbin/usbdump/usbdump.8 index 33b759e3406d..96be9f738e2d 100644 --- a/usr.sbin/usbdump/usbdump.8 +++ b/usr.sbin/usbdump/usbdump.8 @@ -37,6 +37,7 @@ .Op Fl i Ar ifname .Op Fl r Ar file .Op Fl s Ar snaplen +.Op Fl u .Op Fl v .Op Fl w Ar file .Op Fl f Ar filter @@ -89,6 +90,8 @@ This option also works with the -f option. Snapshot .Ar snaplen bytes from each packet. +.It Fl u +Unbuffered output. .It Fl v Enable debugging messages. When defined multiple times the verbosity level increases. diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c index 9c4b6c67c07d..887e2baeed26 100644 --- a/usr.sbin/usbdump/usbdump.c +++ b/usr.sbin/usbdump/usbdump.c @@ -829,7 +829,7 @@ main(int argc, char *argv[]) const char *optstring; char *pp; - optstring = "b:d:hi:r:s:vw:f:"; + optstring = "b:d:hi:r:s:uvw:f:"; while ((o = getopt(argc, argv, optstring)) != -1) { switch (o) { case 'b': @@ -899,6 +899,10 @@ main(int argc, char *argv[]) if (snapshot == 0) snapshot = -1; break; + case 'u': + setbuf(stdout, NULL); + setbuf(stderr, NULL); + break; case 'v': verbose++; break;