Re: 1.5.x Shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris <vdr@xxxxxxxxxxxxxxxxx> 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.

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@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux