From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADB7EA0613 for ; Mon, 23 Sep 2019 13:32:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D58451BEA8; Mon, 23 Sep 2019 13:32:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id DEE431BEA5 for ; Mon, 23 Sep 2019 13:32:39 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8NBUbke013019; Mon, 23 Sep 2019 04:32:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=diXBbT/7UDfE8PGNTtWpEiCbF6zK5Cu6Ek/YkfOib7o=; b=pW39FwRzf1fM6Rs8M71FtxQDuzRAzoq+vEAE0a8kYHlIsIn2g/uOM+YwWl9sRq8uv7Sf MQajDle8j0DlrmMQK0TzbVb+QsCVJim2NK5GOBvn2O1AxFYAIE8zoX1tsjQs26ybaucV tc50D5ZPiL3WeK7QxBPi2CaGZRVVk+kEkTF6/iajahOCRz3t49sbQBQM0tvVhfbj0++B gnDkIqvdDUpF93k4Il5uEGZsnFuDHx/0/zdJa+bnf80SyvRVITITi/7OzD3XrQcqTLWA 6IwtIj3jOtB7vz83HkinTOInFjGS1VrK/hL+aWMeWPUbU6IczYKAsl+JVJCy5xiiQgJw iQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2v5h7qe5my-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2019 04:32:38 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 23 Sep 2019 04:32:37 -0700 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (104.47.48.56) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 23 Sep 2019 04:32:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M2saq10M3R+I5Q6I18/N7Pu7Luu1bnTkYh+FztHx9MtyZb8qAuFkn9rT/+5tani10CehSt6YvLr+o0cA+p8Jmb1Of8JE0YHUKm2LT2mt5LmSdIWpTW94htfNPQkLMG5EBFwvAkO5ejl2ofX0Tj9q/Gg3BQz8CranDDmCMF0+5gj2BQCMxXbwwOg/WBzBdwkcImU/Ey0d7ar/ebiQYkXn6nVJImYACmn0ixbOdg04mTZKwe/Krl1MuM+JruOCi83gZZEE8u06GGoNIpnen/v+ajNAS48nVv0uNrKCzI/LJ569DruHxB5OZjZC9eyXPaaonIz/Ufawbgn19mKo+pwSyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=diXBbT/7UDfE8PGNTtWpEiCbF6zK5Cu6Ek/YkfOib7o=; b=QEYSpWbzerr1o/eF8N0M1BL9+9Ep4e/EP60jzSoGRTxRW3PkmM+bxATN1HbmVZO90KpxxXQttvIEUnmek4XzbLJLTrioLOMPXlAw72UssTFhZu0tIoxDQcybeyZ7AgNPCNwU+U/mot3U4X4otBPl/OvWMvTMxK8l7UK7VK7nTvXDzIc/l9rg1enNi3gY9ChPeTEOJ5xOML+37EwK7UKCY8MBS2UYPbFNTqWhF5rpX+M56RyzbvQoGPFpZMv2s16FP6uEeK3wyyPmLy3x6Tbr3AvFCt1HuQ0n5AGn5jWPC6Q5S6osyDuZjK7p1IjpqNvMrbIW/QVg33++abLqrJNT0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=diXBbT/7UDfE8PGNTtWpEiCbF6zK5Cu6Ek/YkfOib7o=; b=kIJyfp2/t/NlDM7J3upqEx9ChhZHV60s8DoYq16CB6JRdL1gdt5YiGchA/ZN3IKnwV+yjX5pNkjXfD0qjqZzBWzQ6ZgJfkK48SYfvDVV0MXblP1VN0Th2ChMUEb4kEb/44uzBi2nb76YLa244Z9rt5Y4vMFs1Za5TcPSgtiQjxY= Received: from MN2PR18MB2640.namprd18.prod.outlook.com (20.179.81.96) by MN2PR18MB2990.namprd18.prod.outlook.com (20.179.22.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Mon, 23 Sep 2019 11:32:36 +0000 Received: from MN2PR18MB2640.namprd18.prod.outlook.com ([fe80::893d:42eb:9470:9501]) by MN2PR18MB2640.namprd18.prod.outlook.com ([fe80::893d:42eb:9470:9501%7]) with mapi id 15.20.2284.023; Mon, 23 Sep 2019 11:32:35 +0000 From: Krzysztof Kanas To: Krzysztof Kanas , "dev@dpdk.org" , "thomas@monjalon.net" , "ferruh.yigit@intel.com" Thread-Topic: [dpdk-dev] [PATCH v2] test: fix process dup fd close Thread-Index: AQHVYXPEfg8vjJs8XUO1HDtjvJTUeKc5QkaA Date: Mon, 23 Sep 2019 11:32:35 +0000 Message-ID: <20190923113233.GA3341@kk-box-0> References: <20190902075251.2917-1-kkanas@marvell.com> <20190902094939.20482-1-kkanas@marvell.com> In-Reply-To: <20190902094939.20482-1-kkanas@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [199.233.58.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e3653b09-4e00-4102-9ede-08d74019bb79 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2990; x-ms-traffictypediagnostic: MN2PR18MB2990: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:48; x-forefront-prvs: 0169092318 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(7916004)(4636009)(396003)(346002)(39860400002)(376002)(366004)(136003)(189003)(199004)(6436002)(3846002)(9686003)(6512007)(2201001)(86362001)(6246003)(7736002)(305945005)(14444005)(256004)(11346002)(478600001)(6116002)(76176011)(486006)(66556008)(66446008)(91956017)(71190400001)(71200400001)(26005)(446003)(102836004)(14454004)(64756008)(53546011)(6506007)(66066001)(476003)(186003)(33716001)(316002)(81166006)(81156014)(8676002)(25786009)(6486002)(2501003)(229853002)(76116006)(66476007)(110136005)(66946007)(99286004)(1076003)(2906002)(33656002)(8936002)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2990; H:MN2PR18MB2640.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: qpEuCCq3F0c2FHDsrGoG9G4qSQ1Jj3wISzOO5Q6YqRLo2WB8QshHo0uk+nMKmhoSbkWYoAW/6pqNanIJYnmbPzFEO9DlktiTYZMg0M5bFNkMIMr5lC7Jz2H+gr4I87MKtMpSL3fo7ZrV1qYbLmyTAkqDKFDG0WNVdWxCp5YQRCBUfFzjPmeSx9lX1kkHMMGo1ljeM09bvlHmwzh64FZ3GB5Hta0PkIOIjACi8y5xjmYJo9XlhtD+fU6PrCwTwFqozafe+cFLPXeuDTIDs+rYYycM8vJLp5Cs3tpxSoFQzjzTGv/YMG2AF7qPmsHfRszYlt2AFLWxSgZOXRC7YpfJ21PTS+mz6SUFzzi5SIgeQ1Q66i5A0K29WFFeubxIPQjZuqlq09fH3dYjaQS8Z3WbWaw41K2YdTg9tVkqRGEb5lw= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e3653b09-4e00-4102-9ede-08d74019bb79 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2019 11:32:35.8745 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SCwxPtgTxiPLiV7BjZH2N3CZzBNQW5FK4InyMWs0/Al3iVYjzTagIpstvwHvTzemeq6bsk+jl6K6WxgMbLJYIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2990 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-23_04:2019-09-23,2019-09-23 signatures=0 Subject: Re: [dpdk-dev] [PATCH v2] test: fix process dup fd close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Ping.. On 19-09-02 11:49, kkanas@marvell.com wrote: > From: Krzysztof Kanas >=20 > process_dup was intending to close it's own fd's but failed to do so >=20 > Fixes: af75078fece3 ("first public release") >=20 > Signed-off-by: Krzysztof Kanas > --- > v2: > * remove unnecessary commit msg information >=20 > app/test/process.h | 40 +++++++++++++++++++++++++++++++++++----- > 1 file changed, 35 insertions(+), 5 deletions(-) >=20 > diff --git a/app/test/process.h b/app/test/process.h > index 128ce41219a1..2a6428f104e1 100644 > --- a/app/test/process.h > +++ b/app/test/process.h > @@ -11,6 +11,7 @@ > #include /* NULL */ > #include /* strerror */ > #include /* readlink */ > +#include > #include > =20 > #include /* strlcpy */ > @@ -40,8 +41,12 @@ process_dup(const char *const argv[], int numargs, con= st char *env_value) > { > int num; > char *argv_cpy[numargs + 1]; > - int i, fd, status; > + int i, fd, fdir, status; > + struct dirent *dirent =3D NULL; > + const char *procdir =3D "/proc/self/fd/"; > char path[32]; > + char *endptr; > + DIR *dir =3D NULL; > #ifdef RTE_LIBRTE_PDUMP > pthread_t thread; > #endif > @@ -58,11 +63,36 @@ process_dup(const char *const argv[], int numargs, co= nst char *env_value) > =20 > /* close all open file descriptors, check /proc/self/fd to only > * call close on open fds. Exclude fds 0, 1 and 2*/ > - for (fd =3D getdtablesize(); fd > 2; fd-- ) { > - snprintf(path, sizeof(path), "/proc/" exe "/fd/%d", fd); > - if (access(path, F_OK) =3D=3D 0) > - close(fd); > + dir =3D opendir(procdir); > + > + if (dir =3D=3D NULL) { > + rte_panic("Error opening %s: %s\n", procdir, > + strerror(errno)); > + } > + > + fdir =3D dirfd(dir); > + if (fdir < 0) { > + status =3D errno; > + closedir(dir); > + rte_panic("Error %d obtaining fd for dir %s: %s\n", > + fdir, procdir, strerror(status)); > } > + > + while ((dirent =3D readdir(dir)) !=3D NULL) { > + errno =3D 0; > + fd =3D strtol(dirent->d_name, &endptr, 10); > + if (errno !=3D 0 || dirent->d_name =3D=3D endptr) { > + printf("Error converint name fd %d %s:\n", > + fd, dirent->d_name); > + continue; > + } > + > + if (fd =3D=3D fdir || fd <=3D 2) > + continue; > + > + close(fd); > + } > + > printf("Running binary with argv[]:"); > for (i =3D 0; i < num; i++) > printf("'%s' ", argv_cpy[i]); > --=20 > 2.21.0 >=20 --=20 - Regards, Krzysztof(Chris) Kanas=