From 1d33264e66e79dbf0bd71863e9021ce7aead18ee Mon Sep 17 00:00:00 2001 From: chandrakishorSingh Date: Mon, 27 Feb 2023 21:33:55 +0530 Subject: [PATCH] Fix the extraction of pid from child process --- attack_broker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/attack_broker.py b/attack_broker.py index 304f39a..4dd59d4 100644 --- a/attack_broker.py +++ b/attack_broker.py @@ -100,7 +100,12 @@ def main(): p2 = subprocess.Popen('./run.sh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') time.sleep(2) child = subprocess.Popen('pgrep xterm', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') - pid = int(child.communicate()[0].split('\n')[0]) + x = child.communicate()[0] + x = int(x.title().decode('utf-8').split('\n')[0]) + print(x, type(x)) + #pid = int(child.communicate()[0].split('\n')[0]) + pid = x + #pid = int(child.communicate()[0].split('\n')[0]) print("The Simulation is running!") print("Process PID: "+str(pid)) while is_running(pid):