public function __destruct() { if (0 !== $this->pid && posix_getpid() === $this->oid) { // Only kill in owner process. $this->kill(); // Will only terminate if the process is still running. } }