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 39E5043212; Fri, 27 Oct 2023 09:30:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 754D840A76; Fri, 27 Oct 2023 09:30:35 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 2D79640272 for ; Fri, 27 Oct 2023 09:30:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698391829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pM7TJ1qK24ifWbvgs6F+Yjp2hfFdZ0UDZw520KIR1po=; b=L0Z39UgDTXFP+lyHjJ5H+9qj5fCPDDarQpULLdB4+s4SspBShxn9WVagHlkSDkuhNcgZEN 6L7ZfEtASuhSmMDnF6rKjQ34MI0vF5uI3CF/xXxSSQAjwrWOoKFVkMe2tuJPYmdyJ5XSrE KIDYbPzjEoYuKaPKg3Ut1wzkpo2KKHw= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-vPCKq70QNm-ylZal-Xz9Lg-1; Fri, 27 Oct 2023 03:30:27 -0400 X-MC-Unique: vPCKq70QNm-ylZal-Xz9Lg-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-507c996104fso2182871e87.2 for ; Fri, 27 Oct 2023 00:30:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698391826; x=1698996626; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pM7TJ1qK24ifWbvgs6F+Yjp2hfFdZ0UDZw520KIR1po=; b=j+0isT8LBaC1n6lif0t9XA/C8g5X4RU+PcjFRPv+o+Etgu0SkuCDEbQ5vZvJdjZYNM eFg/tstBOdFcHQ96kkuXhOyaNGaS2ESx5zsn9vqgAXo+yaop7xnHfwalgbFjp8qGsoqW YY/kFbqUt+lfsk1yooFdxfVJLTBrjJZW1FtBuHwMkaWRqwI/USC04U3yzd8jmjvVaEUC fbf2Di8hke81ABg9YcPixnKFtHBztJyBvpXMVU3PMQn0tlA8/pgZ7iHFnmaBKFR5lyjW /U6TFGbApPbHaq+LHb57w8rmao/GfoLnYCldZeY/4qRsTTxBR5tNFp276kvtRKv6tIh5 wdLg== X-Gm-Message-State: AOJu0Ywv2Y7J4iVeTc636qNQUpZlY55QBtlKpg+sd9Eyd3FEA86Ux9QD xCfDt/w5XKAbymfKy16rZiGrj4Ec3Wl/+1hrs3rKjAxytJIWMSL9jFbWlN4iVaMo53mvUCqIhgr V6KXrVyqoF8jYHnDXCxMw/dij1ys= X-Received: by 2002:a05:651c:c89:b0:2c5:19ea:b6ac with SMTP id bz9-20020a05651c0c8900b002c519eab6acmr1849569ljb.21.1698391826108; Fri, 27 Oct 2023 00:30:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8msnvwXg2r25k5xzKDB1jNY9pIU5e5uKks8y2jmN2Bbk60G/9M/+ka90zuHnfLa3zDBEm8A5k281xHzx8HyU= X-Received: by 2002:a05:651c:c89:b0:2c5:19ea:b6ac with SMTP id bz9-20020a05651c0c8900b002c519eab6acmr1849544ljb.21.1698391825686; Fri, 27 Oct 2023 00:30:25 -0700 (PDT) MIME-Version: 1.0 References: <20231026171133.250715-1-stephen@networkplumber.org> In-Reply-To: <20231026171133.250715-1-stephen@networkplumber.org> From: David Marchand Date: Fri, 27 Oct 2023 09:30:14 +0200 Message-ID: Subject: Re: [PATCH] testpmd: fix early exit from signal To: Stephen Hemminger Cc: dev@dpdk.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Thu, Oct 26, 2023 at 7:11=E2=80=AFPM Stephen Hemminger wrote: > > Other signals may occur causing read to get interrupted. > Loop until quit flag is set by signal, a character is entered, > or end of file. This fixes bug where testpmd would exit early > because of signal used by TAP device. > > Bugzilla ID: 1305 > Fixes: 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal") We need this fix in LTS. Cc: stable@dpdk.org > Signed-off-by: Stephen Hemminger > --- > app/test-pmd/testpmd.c | 26 +++++++++----------------- > 1 file changed, 9 insertions(+), 17 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index 595b77748c2a..619a59f5b891 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -11,7 +11,6 @@ > #include > #ifndef RTE_EXEC_ENV_WINDOWS > #include > -#include > #endif > #include > #include > @@ -4743,25 +4742,18 @@ main(int argc, char** argv) > } > } else { > char c; > - fd_set fds; > > printf("Press enter to exit\n"); > + while (f_quit =3D=3D 0) { > + /* end-of-file or any character exits loo= p */ > + if (read(0, &c, 1) >=3D 0) > + break; > > - FD_ZERO(&fds); > - FD_SET(0, &fds); > - > - /* wait for signal or enter */ > - ret =3D select(1, &fds, NULL, NULL, NULL); > - if (ret < 0 && errno !=3D EINTR) > - rte_exit(EXIT_FAILURE, > - "Select failed: %s\n", > - strerror(errno)); > - > - /* if got enter then consume it */ > - if (ret =3D=3D 1 && read(0, &c, 1) < 0) > - rte_exit(EXIT_FAILURE, > - "Read failed: %s\n", > - strerror(errno)); > + if (errno =3D=3D EINTR) > + continue; > + rte_exit(EXIT_FAILURE, "Read failed: %s\n= ", > + strerror(errno)); Just a nit here. Indent seems odd, I see an extra whitespace. Otherwise the fix lgtm and resolves the issue reported in bz. Reviewed-by: David Marchand --=20 David Marchand