From: Stephen Hemminger <stephen@networkplumber.org>
To: Kevin Traynor <ktraynor@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>, stable@dpdk.org
Subject: [PATCH 2/5] cmdline: handle EOF as quit
Date: Sat, 31 Aug 2024 10:09:26 -0700 [thread overview]
Message-ID: <20240831171035.27505-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20240831171035.27505-1-stephen@networkplumber.org>
If end of file is reached on input, then cmdline_poll() will
return 1 (ie file has something); and then the cmdline_in()
call to read will return 0. With the existing code,
caller has no way to tell that end of file has been reached
and will retry forever.
A good way to handle this is to make end of file equivalent
to the quit command. Since no more input is possible at that
point.
Fixes: 067855e651d6 ("cmdline: add polling mode")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 415549f1ccce62b82cb182175346904a65f74cec)
---
lib/cmdline/cmdline.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c
index 8f1854cb0b..5600f012c2 100644
--- a/lib/cmdline/cmdline.c
+++ b/lib/cmdline/cmdline.c
@@ -199,9 +199,14 @@ cmdline_poll(struct cmdline *cl)
if (read_status < 0)
return read_status;
- status = cmdline_in(cl, &c, 1);
- if (status < 0 && cl->rdl.status != RDLINE_EXITED)
- return status;
+ if (read_status == 0) {
+ /* end of file is implicit quit */
+ cmdline_quit(cl);
+ } else {
+ status = cmdline_in(cl, &c, 1);
+ if (status < 0 && cl->rdl.status != RDLINE_EXITED)
+ return status;
+ }
}
return cl->rdl.status;
--
2.45.2
next prev parent reply other threads:[~2024-08-31 17:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240831171035.27505-1-stephen@networkplumber.org>
2024-08-31 17:09 ` [PATCH 1/5] cmdline: make rdline status not private Stephen Hemminger
2024-08-31 17:09 ` Stephen Hemminger [this message]
2024-08-31 17:09 ` [PATCH 3/5] app/testpmd: cleanup cleanly from signal Stephen Hemminger
2024-08-31 17:09 ` [PATCH 4/5] app/testpmd: fix early exit " Stephen Hemminger
2024-08-31 17:09 ` [PATCH 5/5] app/testpmd: fix interactive mode on Windows Stephen Hemminger
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=20240831171035.27505-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=ktraynor@redhat.com \
--cc=stable@dpdk.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).