From ce1673803f274fe87814dea15bc10f3647489110 Mon Sep 17 00:00:00 2001 From: cody burkard <cody@onlab.us> Date: Wed, 27 Aug 2014 11:07:22 -0700 Subject: [PATCH] clean up logic for backgrounded processes --- mininet/node.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 4461a401..c6ad614b 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -239,16 +239,12 @@ def sendCmd( self, *args, **kwargs ): # Replace empty commands with something harmless cmd = 'echo -n' self.lastCmd = cmd - if printPid and not isShellBuiltin( cmd ): - if len( cmd ) > 0 and cmd[ -1 ] == '&': - # print ^A{pid}\n so monitor() can set lastPid - cmd += ' printf "\\001%d\\012" $! ' - else: - cmd = 'mnexec -p ' + cmd - # if a builtin command is backgrounded, it yields a PID - elif isShellBuiltin( cmd ): - if len( cmd ) > 0 and cmd[ -1 ] == '&': - cmd += ' printf "\\001%d\\012" $! ' + # if a builtin command is backgrounded, it still yields a PID + if len( cmd ) > 0 and cmd[ -1 ] == '&': + # print ^A{pid}\n so monitor() can set lastPid + cmd += ' printf "\\001%d\\012" $! ' + elif printPid and not isShellBuiltin( cmd ): + cmd = 'mnexec -p ' + cmd self.write( cmd + '\n' ) self.lastPid = None self.waiting = True -- GitLab