From d1b29d58dfc8853d56cdffd612a39fedb2a03ce6 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 22 Mar 2012 14:43:27 -0700 Subject: [PATCH] Fix printing pid for background tasks. --- mininet/node.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index b806da4..62a7040 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -206,15 +206,17 @@ class Node( object ): if not re.search( r'\w', cmd ): # Replace empty commands with something harmless cmd = 'echo -n' - if len( cmd ) > 0 and cmd[ -1 ] == '&': - separator = '&' - cmd = cmd[ :-1 ] - else: - separator = ';' - if printPid and not isShellBuiltin( cmd ): - cmd = 'mnexec -p ' + cmd - self.write( cmd + separator + ' printf "\\177" \n' ) self.lastCmd = cmd + printPid = printPid and not isShellBuiltin( cmd ) + if len( cmd ) > 0 and cmd[ -1 ] == '&': + # print ^A{pid}\n{sentinel} + cmd += ' printf "\\001%d\n\\177" $! \n' + else: + # print sentinel + cmd += '; printf "\\177"' + if printPid and not isShellBuiltin( cmd ): + cmd = 'mnexec -p ' + cmd + self.write( cmd + '\n' ) self.lastPid = None self.waiting = True