From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48558458BC for ; Sat, 31 Aug 2024 19:10:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41EA4402D9; Sat, 31 Aug 2024 19:10:50 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id AF73640263 for ; Sat, 31 Aug 2024 19:10:48 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2054feabfc3so3490915ad.1 for ; Sat, 31 Aug 2024 10:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1725124248; x=1725729048; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7pCZFDzxRrFuoYkf6tTnvUwpgRcYjS3SFWcguPIoXmY=; b=S9gfTCxSKWolW67epchUk6dQxHV1SofqhWevqLt1yhBcFo06mypUCrPJukB0njXdsc WIl1nw1RUD0NxG9ix6jgvfbLdX3UvoFCBa1OUUOGL65JqTgRF1RE9EjgzTaw8iWlrI/G XWKVYKoxZc6Eu8QVuHvGIwaE2cyhs96Ldadhk7598JjPjybHdInTM3QNZw3rLnmISwYg qoKZsbGiCLd5oTDsfuXGNig1Oachb6p5IQ8oHXcqNZxFF3NbuZCiJxVZT0vvpJ6p8uHJ CoLFdRRP19y6oiU6NS1I2BnGRDiMp6HnU7Sr8FFK5hxZYEtjxZ6oYHykH86F8C9n5yNd bymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725124248; x=1725729048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7pCZFDzxRrFuoYkf6tTnvUwpgRcYjS3SFWcguPIoXmY=; b=D+bGFBu5XYQOeBECgcGJaClYc/UEEHWEYKPZFqg1u8uilQZae/9F26wgp+AUbPzmDB HhWcEatHwSPBufqwdEj8OVXNU+5o4xh7qIS4b/VKNKS6halsDn42soj1QXWzAr2UZRda VUXf1tmeuiUPXEpRekc/jOD6Kjx0zoeVpjKRh72UIg8Mm6KIPypoicwnZPJTkJcoFme5 4UcwZrMHEQQPiaxdXIoIHzrwShLdkIFILzB8YjMS/+ZxXrkU+j8Q7M9D8Aw6Gdji/VNE dYAcWomkLXTUSUGKaUrociVFpKyzeMq49hXd7BlA17TDROoJN6NkW5IWdUStCGD8aPWE RZXw== X-Forwarded-Encrypted: i=1; AJvYcCUo3d3jUpQeemBz5QJXWt8obHjA3hODNOHHlO34WmkIfm12UT/jkZjKV9RJ4H6mKmkTn2AuEHc=@dpdk.org X-Gm-Message-State: AOJu0YzaaXu+ltNe0NoGs5gwEo6e2tlT4C3hG6ECrbUrQ1TCwe1CNbY/ ovTXZEJ45CCSB7bRLIKjh8CTqk7Zp0Qz3oX9EIxjYM1hAqnWuiWybzxQPyW5Hac= X-Google-Smtp-Source: AGHT+IHX3JZ34EtKYPot59Ma+QRPnCh6MTCsUE8nLmtAadf9uAugFDOoxuEcu310wqne+SJK19dIuw== X-Received: by 2002:a17:903:1c8:b0:202:71b:fa6 with SMTP id d9443c01a7336-2054477bfd0mr34959805ad.44.1725124247723; Sat, 31 Aug 2024 10:10:47 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152cf12bsm43141735ad.83.2024.08.31.10.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2024 10:10:47 -0700 (PDT) From: Stephen Hemminger To: Kevin Traynor Cc: Stephen Hemminger , stable@dpdk.org Subject: [PATCH 2/5] cmdline: handle EOF as quit Date: Sat, 31 Aug 2024 10:09:26 -0700 Message-ID: <20240831171035.27505-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240831171035.27505-1-stephen@networkplumber.org> References: <20240831171035.27505-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.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 (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