Logo Search packages:      
Sourcecode: kayali version File versions  Download package

def pexpect::spawn::isalive (   self  ) 

This tests if the child process is running or not.
This returns 1 if the child process appears to be running or 0 if not.
This also sets the exitstatus attribute.
It can take literally SECONDS for Solaris to return the right status.
This is the most wiggly part of Pexpect, but I think I've almost got
it nailed down.

Definition at line 529 of file pexpect.py.

00529                      :
        """This tests if the child process is running or not.
        This returns 1 if the child process appears to be running or 0 if not.
        This also sets the exitstatus attribute.
        It can take literally SECONDS for Solaris to return the right status.
        This is the most wiggly part of Pexpect, but I think I've almost got
        it nailed down.
        """
        # I can't use signals. Signals on UNIX suck and they
        # mess up Python pipes (setting SIGCHLD to SIGIGNORE).

        # If this class was created from an existing file descriptor then
        # I just check to see if the file descriptor is still valid.
        if self.pid == -1 and not self.__child_fd_owner: 
            try:
                os.fstat(self.child_fd)
                return 1
            except:
                return 0

        try:
            pid, status = os.waitpid(self.pid, os.WNOHANG)
        except OSError:
            return 0

        # I have to do this twice for Solaris.
        # I can't even believe that I figured this out...
        if pid == 0 and status == 0:
            try:
                pid, status = os.waitpid(self.pid, os.WNOHANG)
                #print 'Solaris sucks'
            except OSError: # This is crufty. When does this happen?
                return 0
            # If pid and status is still 0 after two calls to waitpid() then
            # the process really is alive. This seems to work on all platforms.
            if pid == 0 and status == 0:
                return 1

        # I do not OR this together because I want hooks for debugging.
        if os.WIFEXITED (status):
            self.exitstatus = os.WEXITSTATUS(status)
            return 0
        elif os.WIFSTOPPED (status):
            return 0
        elif os.WIFSIGNALED (status):
            return 0
        else:
            return 0 # Can I ever get here?

    def kill(self, sig):


Generated by  Doxygen 1.6.0   Back to index