[dpdk-dev] daemon process problem in DPDK

Ni, Xun xun.ni at intel.com
Tue Jan 13 03:36:30 CET 2015


Much appericated, Get it now.

Thanks,
Xun

-----Original Message-----
From: Stephen Hemminger [mailto:stephen at networkplumber.org] 
Sent: Tuesday, January 13, 2015 3:14 AM
To: Neil Horman
Cc: Ni, Xun; dev at dpdk.org
Subject: Re: [dpdk-dev] daemon process problem in DPDK

On Mon, 12 Jan 2015 09:52:10 -0500
Neil Horman <nhorman at tuxdriver.com> wrote:

> On Mon, Jan 12, 2015 at 02:28:20PM +0000, Ni, Xun wrote:
> > Hello:
> > 
> >    I have basic questions related to dpdk and trying to find help.
> > 
> >    I am about to create a daemon process, is there a way for other process to know whether the daemon is already created? I doesn't mean to get the pid, because it changes every time.
> > 
> >    If the daemon is created, how do other process to communicate with this 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 between processes.
> > 
> > Thanks,
> > Xun
> > 
> > 
> 
> Thats not really a dpdk question, that a generic programming question.  
> You can do this lots of ways.  Open a socket that other process can 
> connect to on an agreed port, create a shared memory segment, write a 
> file with connect information to a well know location, etc.
> Neil
> 

We did have to make some changes to the basic application model (not in DPDK) to allow for a daemon.

The normal/correct way to make a daemon is to use the daemon glibc call, and this closes all file descriptors etc. Therefore the DPDK (eal) must be initialized after the daemon call.

Also, wanted to make daemon optional for debugging.
This led to change where the main program process application argv first then passes DPDK args as second group. This is the inverse of the example applications.


int
main(int argc, char **argv)
{
	int ret;
        char *progname;

	progname = strrchr(argv[0], '/');
	progname = strdup(progname ? progname + 1 : argv[0]);

	ret = parse_args(argc, argv);
	if (ret < 0)
		return -1;

	argc -= ret;
	argv += ret;

	if (daemon_mode && daemon(1, 1) < 0)
		return -1;

	/* workaround fact that EAL expects progname as first argument */
	argv[0] = progname;

	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		return -1;


More information about the dev mailing list