Attempt to handle interrupts in the middle of CLI commands.
This commit is contained in:
+14
-6
@@ -35,6 +35,17 @@ from cmd import Cmd
|
|||||||
|
|
||||||
from mininet.log import info, output, error
|
from mininet.log import info, output, error
|
||||||
|
|
||||||
|
|
||||||
|
def waitForNode( node ):
|
||||||
|
"Wait for a node to finish, and print its output."
|
||||||
|
while node.waiting:
|
||||||
|
try:
|
||||||
|
data = node.monitor()
|
||||||
|
info( '%s' % data )
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
node.sendInt()
|
||||||
|
|
||||||
|
|
||||||
class CLI( Cmd ):
|
class CLI( Cmd ):
|
||||||
"Simple command-line interface to talk to nodes."
|
"Simple command-line interface to talk to nodes."
|
||||||
|
|
||||||
@@ -54,6 +65,8 @@ class CLI( Cmd ):
|
|||||||
break
|
break
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
info( 'Interrupt\n' )
|
info( 'Interrupt\n' )
|
||||||
|
for node in self.nodelist:
|
||||||
|
waitForNode( node )
|
||||||
|
|
||||||
def emptyline( self ):
|
def emptyline( self ):
|
||||||
"Don't repeat last command when you hit return."
|
"Don't repeat last command when you hit return."
|
||||||
@@ -210,12 +223,7 @@ class CLI( Cmd ):
|
|||||||
rest = ' '.join( rest )
|
rest = ' '.join( rest )
|
||||||
# Run cmd on node:
|
# Run cmd on node:
|
||||||
node.sendCmd( rest, printPid=True )
|
node.sendCmd( rest, printPid=True )
|
||||||
while node.waiting:
|
waitForNode( node )
|
||||||
try:
|
|
||||||
data = node.monitor()
|
|
||||||
info( '%s' % data )
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
node.sendInt()
|
|
||||||
else:
|
else:
|
||||||
self.stdout.write( '*** Unknown syntax: %s\n' % line )
|
self.stdout.write( '*** Unknown syntax: %s\n' % line )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user