Chris <[EMAIL PROTECTED]> wrote:
> My assumption is that the problem occurs because of the missing wait
> call (if SystemExec is called 'detached'). I know, if VDR would wait
> in there, the script wouldn't run simultaneously. But if VDR never
> waits for the child's PID, the child's termination never gets handled
> and imho that's why the script remains as a zombie.
>
> waitpid( -1, &dummy, WNOHANG) called at some place later should do the
> trick. Or waitpid() explicitly for the child's PID, if we want to
> store the PID anywhere.

Advertising

i once found this code somewhere and since use this:
int
System(const string &cmd) {
// The parent process forks and then waits right there for the child
// to terminate. The child process then forks again, giving us achild
// and a grandchild. The child exits immediately (and hence the parent
// waiting for it notices its death and continues to work). Now the
// grandchild does whatever the child was originally supposed to do.
// Since its parent died, it is inherited by init, which will do
// whatever waiting is needed.
switch (fork()) {
case 0:
if (!fork()) system(cmd.c_str());
_exit(0);
break;
case -1: break;
default: wait(NULL);
}
return (0);
}
i didn't look at vdr's SystemExec, but maybe this code snipet comes in
handy.
best regards ...
clemens
_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr