sargon / ddhcpd

A distributed DHCP Daemon
GNU General Public License v3.0
31 stars 12 forks source link

hook: only return empty if no hook is configured #9

Closed christf closed 6 years ago

christf commented 6 years ago

without this the hook will not be executed if configured. Also an empty hook will be executed.

christf commented 6 years ago

there is still no synchronisation done between executions of the hook. We can try getting away with delegating this to the hook itself.

sargon commented 6 years ago

Yeah, delegating this sounds like a reasonable first step. Leave a TODO comment in the code for that, I will have a test on this pr as soon as I find the time.

christf commented 6 years ago

The crashes indeed are gone now. With the latest patch I can see the events triggering on a local machine, yet have to try this in the gluon environment.

sargon commented 6 years ago

How about using exit() in the child process?

christf commented 6 years ago

the child process will exit automatically due to execle and the shell exiting when the script ends. We have to make sure to reap the process, which is what wait() does. This will remove the entry from the process table and free the remaining held resources.

sargon commented 6 years ago

Yes it does that, except in the case when the execution of the new process image fails.

christf commented 6 years ago

if it fails, the process still exits - how would that change things?

sargon commented 6 years ago

No, if there is something utterly going wrong than the child process is keep going. Bad example:

$ cat test.c 
#include <unistd.h>
#include <stdio.h>

void main(){
  execle("/bin/not-there","not-there",NULL,NULL);
  printf("Pong\n");
}

$ ./a.out 
Pong

So according to the man page that's normal behaviour, whenever something is going wrong.

christf commented 6 years ago

Thanks for the help, I appreciate it