Here are some answers to brewbuck:
The call to execv does not fail, it is checked:
Code:
int ret;
...
...
ret = execv("path_to_3rd_party_binary", cmd);
exit(1);
// Check ret
The reason is there,
after the kill, is that a lot of defunct processes
appeared in the system if the wait was not there...
And that is interesting, because:
The child sets up a signal handler:
Code:
// Remove anachronism warning
extern "C" {
typedef void(*funPtr)(int);
}
void terminateOnSignal(int signo) {
_exit(1);
}
//In child: {
signal(SIGTERM, reinterpret_cast<funPtr>(terminateOnSignal));
// }
So the the parent calls kill the child's sig handler will execute..
So it just seems that if a timeout or anything occurs in the call to
execv, the calls will keep on failing... And even if I _exit the children
upon kill there will be defunct processes if not wait is called..
Some questions:
Should I set up signaling differently between child and parent?
Could I use anything else but _exit(1) when exiting the application..?
As mentioned, the strange thing is that, if I restart the program from
a terminal it'll continue work as anticipated, but if I restart it using
cron, or even if I have a little script to run when the program has
gone down, to execute it again, it will fail... The file will just not
be printed to... it'll continue to be 0 byte large..
BR
Tobias