linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH] iw:  Flush stdout when printing events.
Date: Tue, 28 Sep 2010 17:30:44 -0700	[thread overview]
Message-ID: <1285720244-26149-1-git-send-email-greearb@candelatech.com> (raw)

From: Ben Greear <greearb@candelatech.com>

This lets one pipe output of iw event properly.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 129db1a... 60bafc5... M	event.c
 event.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/event.c b/event.c
index 129db1a..60bafc5 100644
--- a/event.c
+++ b/event.c
@@ -130,12 +130,16 @@ static void parse_cqm_event(struct nlattr *tb)
 
 static int print_event(struct nl_msg *msg, void *arg)
 {
-#define PARSE_BEACON_CHAN(_attr, _chan) do { \
-	r = parse_beacon_hint_chan(tb[_attr], \
-				   &_chan); \
-	if (r) \
-		return NL_SKIP; \
-} while (0)
+
+#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
+		r = parse_beacon_hint_chan(tb[_attr],	\
+					   &_chan);	\
+		if (r) {				\
+			fflush(stdout);			\
+			return NL_SKIP;			\
+		}					\
+	} while (0)
+
 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
 	struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
 	struct print_event_args *args = arg;
@@ -349,6 +353,7 @@ static int print_event(struct nl_msg *msg, void *arg)
 		break;
 	}
 
+	fflush(stdout);
 	return NL_SKIP;
 #undef PARSE_BEACON_CHAN
 }
@@ -369,8 +374,8 @@ static int wait_event(struct nl_msg *msg, void *arg)
 	for (i = 0; i < wait->n_cmds; i++) {
 		if (gnlh->cmd == wait->cmds[i]) {
 			wait->cmd = gnlh->cmd;
-		if (wait->pargs)
-			print_event(msg, wait->pargs);
+			if (wait->pargs)
+				print_event(msg, wait->pargs);
 		}
 	}
 
-- 
1.5.4.3


             reply	other threads:[~2010-09-29  0:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-29  0:30 greearb [this message]
2010-09-29  6:59 ` [PATCH] iw: Flush stdout when printing events Johannes Berg
2010-09-29 20:21   ` Ben Greear
2010-09-29 20:29     ` Johannes Berg
2010-09-29 20:33       ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285720244-26149-1-git-send-email-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).