diff --git a/mininet/node.py b/mininet/node.py index 842b0dc..b0a3951 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -212,7 +212,7 @@ class Node( object ): # Subshell I/O, commands and control def read( self, maxbytes=1024 ): - """Buffered read from node, non-blocking. + """Buffered read from node, potentially blocking. maxbytes: maximum number of bytes to return""" count = len( self.readbuf ) if count < maxbytes: @@ -227,7 +227,7 @@ class Node( object ): return result def readline( self ): - """Buffered readline from node, non-blocking. + """Buffered readline from node, potentially blocking. returns: line (minus newline) or None""" self.readbuf += self.read( 1024 ) if '\n' not in self.readbuf: @@ -259,9 +259,10 @@ class Node( object ): def waitReadable( self, timeoutms=None ): """Wait until node's output is readable. - timeoutms: timeout in ms or None to wait indefinitely.""" + timeoutms: timeout in ms or None to wait indefinitely. + returns: result of poll()""" if len( self.readbuf ) == 0: - self.pollOut.poll( timeoutms ) + return self.pollOut.poll( timeoutms ) def sendCmd( self, *args, **kwargs ): """Send a command, followed by a command to echo a sentinel, @@ -303,7 +304,9 @@ class Node( object ): Set self.waiting to False if command has completed. timeoutms: timeout in ms or None to wait indefinitely findPid: look for PID from mnexec -p""" - self.waitReadable( timeoutms ) + ready = self.waitReadable( timeoutms ) + if not ready: + return '' data = self.read( 1024 ) pidre = r'\[\d+\] \d+\r\n' # Look for PID