Make sure we 'sudo kill' our sudo pexpect process in close().

This should more reliably shut down pexpect subprocesses when
build.py exits before completion.
This commit is contained in:
Bob Lantz
2014-09-24 11:57:46 -07:00
parent 12095a12f4
commit 61760eabc5
+7 -2
View File
@@ -441,7 +441,12 @@ def boot( cow, kernel, initrd, logfile, memory=1024 ):
returns: pexpect object to qemu process"""
# pexpect might not be installed until after depend() is called
global pexpect
import pexpect
if not pexpect:
import pexpect
class Spawn( pexpect.spawn ):
"Subprocess is sudo, so we have to sudo kill it"
def close( self, force=False ):
srun( 'kill %d' % self.pid )
arch = archFor( kernel )
log( '* Detected kernel architecture', arch )
if NoKVM:
@@ -462,7 +467,7 @@ def boot( cow, kernel, initrd, logfile, memory=1024 ):
cmd = ' '.join( cmd )
log( '* BOOTING VM FROM', cow )
log( cmd )
vm = pexpect.spawn( cmd, timeout=TIMEOUT, logfile=logfile )
vm = Spawn( cmd, timeout=TIMEOUT, logfile=logfile )
return vm