Merge pull request #364 from cdburkard/patches/testCPULimit
Fix output of backgrounded processes
This commit is contained in:
+1
-1
@@ -740,7 +740,7 @@ class Mininet( object ):
|
|||||||
sleep( 1 )
|
sleep( 1 )
|
||||||
outputs.append( quietRun( cmd ).strip() )
|
outputs.append( quietRun( cmd ).strip() )
|
||||||
for h in hosts:
|
for h in hosts:
|
||||||
h.cmd( 'kill %1' )
|
h.cmd( 'kill $!' )
|
||||||
cpu_fractions = []
|
cpu_fractions = []
|
||||||
for test_output in outputs:
|
for test_output in outputs:
|
||||||
# Split by line. Ignore first line, which looks like this:
|
# Split by line. Ignore first line, which looks like this:
|
||||||
|
|||||||
+12
-7
@@ -160,6 +160,7 @@ class Node( object ):
|
|||||||
self.pollOut.poll()
|
self.pollOut.poll()
|
||||||
self.waiting = False
|
self.waiting = False
|
||||||
self.cmd( 'stty -echo' )
|
self.cmd( 'stty -echo' )
|
||||||
|
self.cmd( 'set +m' )
|
||||||
|
|
||||||
def cleanup( self ):
|
def cleanup( self ):
|
||||||
"Help python collect its garbage."
|
"Help python collect its garbage."
|
||||||
@@ -238,12 +239,12 @@ class Node( object ):
|
|||||||
# Replace empty commands with something harmless
|
# Replace empty commands with something harmless
|
||||||
cmd = 'echo -n'
|
cmd = 'echo -n'
|
||||||
self.lastCmd = cmd
|
self.lastCmd = cmd
|
||||||
if printPid and not isShellBuiltin( cmd ):
|
# if a builtin command is backgrounded, it still yields a PID
|
||||||
if len( cmd ) > 0 and cmd[ -1 ] == '&':
|
if len( cmd ) > 0 and cmd[ -1 ] == '&':
|
||||||
# print ^A{pid}\n so monitor() can set lastPid
|
# print ^A{pid}\n so monitor() can set lastPid
|
||||||
cmd += ' printf "\\001%d\n" $! \n'
|
cmd += ' printf "\\001%d\\012" $! '
|
||||||
else:
|
elif printPid and not isShellBuiltin( cmd ):
|
||||||
cmd = 'mnexec -p ' + cmd
|
cmd = 'mnexec -p ' + cmd
|
||||||
self.write( cmd + '\n' )
|
self.write( cmd + '\n' )
|
||||||
self.lastPid = None
|
self.lastPid = None
|
||||||
self.waiting = True
|
self.waiting = True
|
||||||
@@ -258,9 +259,13 @@ class Node( object ):
|
|||||||
timeoutms: timeout in ms or None to wait indefinitely."""
|
timeoutms: timeout in ms or None to wait indefinitely."""
|
||||||
self.waitReadable( timeoutms )
|
self.waitReadable( timeoutms )
|
||||||
data = self.read( 1024 )
|
data = self.read( 1024 )
|
||||||
|
pidre = r'\[\d+\] \d+\r\n'
|
||||||
# Look for PID
|
# Look for PID
|
||||||
marker = chr( 1 ) + r'\d+\r\n'
|
marker = chr( 1 ) + r'\d+\r\n'
|
||||||
if findPid and chr( 1 ) in data:
|
if findPid and chr( 1 ) in data:
|
||||||
|
# suppress the job and PID of a backgrounded command
|
||||||
|
if re.findall( pidre, data ):
|
||||||
|
data = re.sub( pidre, '', data )
|
||||||
# Marker can be read in chunks; continue until all of it is read
|
# Marker can be read in chunks; continue until all of it is read
|
||||||
while not re.findall( marker, data ):
|
while not re.findall( marker, data ):
|
||||||
data += self.read( 1024 )
|
data += self.read( 1024 )
|
||||||
@@ -1264,7 +1269,7 @@ class Controller( Node ):
|
|||||||
if self.cdir is not None:
|
if self.cdir is not None:
|
||||||
self.cmd( 'cd ' + self.cdir )
|
self.cmd( 'cd ' + self.cdir )
|
||||||
self.cmd( self.command + ' ' + self.cargs % self.port +
|
self.cmd( self.command + ' ' + self.cargs % self.port +
|
||||||
' 1>' + cout + ' 2>' + cout + '&' )
|
' 1>' + cout + ' 2>' + cout + ' &' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
|
|||||||
Reference in New Issue
Block a user