From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0F5665A11 for ; Tue, 13 Jan 2015 03:36:45 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 12 Jan 2015 18:33:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="511290934" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga003.jf.intel.com with ESMTP; 12 Jan 2015 18:30:37 -0800 Received: from kmsmsx154.gar.corp.intel.com (172.21.73.14) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 13 Jan 2015 10:36:31 +0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by KMSMSX154.gar.corp.intel.com (172.21.73.14) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 13 Jan 2015 10:36:31 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.92]) with mapi id 14.03.0195.001; Tue, 13 Jan 2015 10:36:30 +0800 From: "Ni, Xun" To: Stephen Hemminger , Neil Horman Thread-Topic: [dpdk-dev] daemon process problem in DPDK Thread-Index: AQHQLpwnyaA2gtznGE+uuLneuFb5FZy9Vfcw Date: Tue, 13 Jan 2015 02:36:30 +0000 Message-ID: <91E2D863603AD4478F101CE81E76E45D01C38696@SHSMSX103.ccr.corp.intel.com> References: <91E2D863603AD4478F101CE81E76E45D01C3839B@SHSMSX103.ccr.corp.intel.com> <20150112145210.GC23467@hmsreliant.think-freely.org> <20150112111421.613ffe97@urahara> In-Reply-To: <20150112111421.613ffe97@urahara> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] daemon process problem in DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2015 02:36:46 -0000 Much appericated, Get it now. Thanks, Xun -----Original Message----- From: Stephen Hemminger [mailto:stephen@networkplumber.org]=20 Sent: Tuesday, January 13, 2015 3:14 AM To: Neil Horman Cc: Ni, Xun; dev@dpdk.org Subject: Re: [dpdk-dev] daemon process problem in DPDK On Mon, 12 Jan 2015 09:52:10 -0500 Neil Horman wrote: > On Mon, Jan 12, 2015 at 02:28:20PM +0000, Ni, Xun wrote: > > Hello: > >=20 > > I have basic questions related to dpdk and trying to find help. > >=20 > > I am about to create a daemon process, is there a way for other proc= ess to know whether the daemon is already created? I doesn't mean to get th= e pid, because it changes every time. > >=20 > > If the daemon is created, how do other process to communicate with t= his daemon? Dpdk seems to have rte ring but it only exists on the Ethernet,= while I am talking about the process within the same computer, and the way= like share-memory, but I didn't find examples about the share memory betwe= en processes. > >=20 > > Thanks, > > Xun > >=20 > >=20 >=20 > Thats not really a dpdk question, that a generic programming question. =20 > You can do this lots of ways. Open a socket that other process can=20 > connect to on an agreed port, create a shared memory segment, write a=20 > file with connect information to a well know location, etc. > Neil >=20 We did have to make some changes to the basic application model (not in DPD= K) to allow for a daemon. The normal/correct way to make a daemon is to use the daemon glibc call, an= d this closes all file descriptors etc. Therefore the DPDK (eal) must be in= itialized after the daemon call. Also, wanted to make daemon optional for debugging. This led to change where the main program process application argv first th= en passes DPDK args as second group. This is the inverse of the example app= lications. int main(int argc, char **argv) { int ret; char *progname; progname =3D strrchr(argv[0], '/'); progname =3D strdup(progname ? progname + 1 : argv[0]); ret =3D parse_args(argc, argv); if (ret < 0) return -1; argc -=3D ret; argv +=3D ret; if (daemon_mode && daemon(1, 1) < 0) return -1; /* workaround fact that EAL expects progname as first argument */ argv[0] =3D progname; ret =3D rte_eal_init(argc, argv); if (ret < 0) return -1;