Question

I'am using the fonction posix_spawn to run a thread from the executable file "/sbin/udhcpc",like this:

char* argv[] = {(char*)UDHCPC_EXECUTABLE_FILE, (char*)"-s", (char*)UDHCPC_NOTIFIER,
                                                   (char*)"-i", (char*)INTERFACE_NAME,
                                                   (char*)"-p", (char*)UDHCPC_PID,
                                                   NULL};
char* envp[] = {NULL};
int status;

// Start UDHCPC daemon (lock DaemonProcess against concurrent modifications)
{
  CMutex lock(&self->m_ConnectionStatusLock);

  status = posix_spawn(&self->m_DaemonProcess, UDHCPC_EXECUTABLE_FILE, NULL, NULL, argv, envp);

  if (status != 0)
  {
     cout<<"UDHCPC daemon start failed (%s)"<<endl;

  }

}

My Problem is:

when i use the command line "PS" , in order to see the PID of my new process , i see that first posix spawn create a udhcpc thread ( a zombie thread that disappeared very quickly ) , and after that a permanent process with the configuration of the variable "argv".

So, the problem is that in the variable Process Deamon ID "m_DaemonProcess", I get the PID of the zombie process. is that normal. how can i get directly the PID of the permanent process?

please help thanks

Was it helpful?

Solution

The udhcpc client should accept an -f or --foreground option, which causes it to not perform it's own fork-exec, which is why you get the temporary pid.

You also are using the pidfile option, so you could read that content as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top