From 3b24bd7abd840479eeaedc63a4ee46c33853014f Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Tue, 8 Jul 2014 02:22:02 -0700
Subject: [PATCH] Restore non-mnexec pid detection for background commands

---
 mininet/node.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mininet/node.py b/mininet/node.py
index 258ce84e..7bb80ba5 100644
--- a/mininet/node.py
+++ b/mininet/node.py
@@ -234,7 +234,11 @@ def sendCmd( self, *args, **kwargs ):
             cmd = 'echo -n'
         self.lastCmd = cmd
         if printPid and not isShellBuiltin( cmd ):
-            cmd = 'mnexec -p ' + cmd
+            if len( cmd ) > 0 and cmd[ -1 ] == '&':
+                # print ^A{pid}\n so monitor() can set lastPid
+                cmd += ' printf "\\001%d\n" $! \n'
+            else:
+                cmd = 'mnexec -p ' + cmd
         self.write( cmd + '\n' )
         self.lastPid = None
         self.waiting = True
-- 
GitLab