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

def pexpect::spawn::sendeof (   self  ) 

This sends an EOF to the child.
This sends a character which causes the pending parent output
buffer to be sent to the waiting child program without
waiting for end-of-line. If it is the first character of the
line, the read() in the user program returns 0, which
signifies end-of-file. This means to work as expected 
a sendeof() has to be called at the begining of a line. 
This method does not send a newline. It is the responsibility
of the caller to ensure the eof is sent at the beginning of a line.

Definition at line 498 of file pexpect.py.

00498                      :
        """This sends an EOF to the child.
        This sends a character which causes the pending parent output
        buffer to be sent to the waiting child program without
        waiting for end-of-line. If it is the first character of the
        line, the read() in the user program returns 0, which
        signifies end-of-file. This means to work as expected 
        a sendeof() has to be called at the begining of a line. 
        This method does not send a newline. It is the responsibility
        of the caller to ensure the eof is sent at the beginning of a line.
        """
        ### Hmmm... how do I send an EOF?
        ###C  if ((m = write(pty, *buf, p - *buf)) < 0)
        ###C      return (errno == EWOULDBLOCK) ? n : -1;
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd) # remember current state
        new = termios.tcgetattr(fd)
        new[3] = new[3] | termios.ICANON # lflags
        # use try/finally to ensure state gets restored
        try:
            # EOF is recognized when ICANON is set, so make sure it is set.
            termios.tcsetattr(fd, termios.TCSADRAIN, new)
            os.write (self.child_fd, '%c' % termios.CEOF)
        finally:
            termios.tcsetattr(fd, termios.TCSADRAIN, old) # restore state

    def eof (self):


Generated by  Doxygen 1.6.0   Back to index