Fix printing pid for background tasks.

This commit is contained in:
Bob Lantz
2012-03-22 14:43:27 -07:00
parent ba8d4f9bd6
commit d1b29d58df
+7 -5
View File
@@ -206,15 +206,17 @@ class Node( object ):
if not re.search( r'\w', cmd ):
# Replace empty commands with something harmless
cmd = 'echo -n'
self.lastCmd = cmd
printPid = printPid and not isShellBuiltin( cmd )
if len( cmd ) > 0 and cmd[ -1 ] == '&':
separator = '&'
cmd = cmd[ :-1 ]
# print ^A{pid}\n{sentinel}
cmd += ' printf "\\001%d\n\\177" $! \n'
else:
separator = ';'
# print sentinel
cmd += '; printf "\\177"'
if printPid and not isShellBuiltin( cmd ):
cmd = 'mnexec -p ' + cmd
self.write( cmd + separator + ' printf "\\177" \n' )
self.lastCmd = cmd
self.write( cmd + '\n' )
self.lastPid = None
self.waiting = True