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 AD5D141BC0; Fri, 3 Feb 2023 20:14:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3330242D49; Fri, 3 Feb 2023 20:14:18 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id B61134067B for ; Fri, 3 Feb 2023 20:14:15 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso8765910pju.0 for ; Fri, 03 Feb 2023 11:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; 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=oZ73CW2sv1WMVI5SidqFd5zlO8UshcK9PT2qEQBScYQ=; b=eU/HxpMAB4SVoruqG8RINpuhgaS58R89gh4b4p6xTmaoVWEYXfGsyFy0DSa2LoDeyP 4ruyOm3bSApbSg7fOpnzb8o589ybELn+OQw6A4DvpfJWzfw03gE2IXHMDidzBO3JdWT+ 4kWhjFH30pQDKPCDnUkAC34QAmqtO1eU9rdgdNeMr6Ko2umx8DRUanVPA2zRUxVy1j1s 8spDC9g2gk3asyJR3thhPUf0sHOWCpbB8dSc3amsdMDJIeBqrJ3hMwfGFKmD4sIr/N91 Slf2MnluXdeacnmkFziUzmeKAozPcX7wXvdBiks05PjDxI9UUEUjH/LPSiTHSpD6pEya xdCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=oZ73CW2sv1WMVI5SidqFd5zlO8UshcK9PT2qEQBScYQ=; b=eOub30p1HyXE7kUSHuO5uTexH6IgddWkNid/IGk2cmAN/uQ2wQEBAvu6iljHpCoUpO CjWfmK3Whv4eqJAjYEhRV1hJvI05pDX3+nPKAUvCptBZ9MH3t/kh4Fq1z9NGRnu2H7wG F0YES5eaE/ERLmaNImJ5POzPwA12Im31SHZmBGrFACOp4Cih72CeDuLcauK6lujG51tM b/qtDNsuAuAyBOSshPz44Oae7YfknEPvmjzATuRSpo7ckHyRPTXT7U1gIc1ft/yC/8Qa WB/i5QZ367c7RQ+KuLIHBM7X61TP760pylqqZQ4zRfmj/ixtzkr/R9EKB3XUL5EKm4q7 mvdg== X-Gm-Message-State: AO0yUKXVK8b6BmNixybrIfzlxC7iAC3bd8sPcb2jzC35E+X/hD85CMwy NNrEh7FWWCPlaSwVHHRKh4tjV5vpK+S1iYXRX+RHdA== X-Google-Smtp-Source: AK7set+A8j83A5Wz7U/08raGgbns7iPdg0MDB7iA7Bf5XctpLTh0CS8mery/ZZ79awZlgOzflcxprQ== X-Received: by 2002:a05:6a20:e18c:b0:bd:8b67:4e6b with SMTP id ks12-20020a056a20e18c00b000bd8b674e6bmr11566802pzb.19.1675451654691; Fri, 03 Feb 2023 11:14:14 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l9-20020a056a00140900b00593edee1af6sm2200898pfu.67.2023.02.03.11.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:14:14 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger , pawelx.wodkowski@intel.com Subject: [PATCH v11 2/3] cmdline: handle EOF in cmdline_poll Date: Fri, 3 Feb 2023 11:14:08 -0800 Message-Id: <20230203191409.97567-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203191409.97567-1-stephen@networkplumber.org> References: <20230130200914.22049-1-stephen@networkplumber.org> <20230203191409.97567-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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: pawelx.wodkowski@intel.com Signed-off-by: Stephen Hemminger --- Note: cmdline_poll() should not have been added back in 2015, looks like there is no users, and no tests for this. 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 e1009ba4c413..8ad0690d8533 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -197,9 +197,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.39.0