'This is borrowed from subprocess.Popen.'

def poll(self):

    if (self.returncode is None):
        try:
            (pid, sts) = os.waitpid(self.pid, os.WNOHANG)
            if (pid == self.pid):
                self._handle_exitstatus(sts)
        except os.error:
            pass
    return self.returncode
