def example_function(self):
number = self.lineEdit_4.text() #Takes input from GUI
start = "python3 /path/to/launched/script.py "+variable1+" "+variable2+" "+variable3 #Bash command to execute python script with args.
for i in range(0,number):
x = subprocess.Popen(start,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)#Launch another script as a subprocess
So, this code launches another Python script for a number of times, each python script contains an infinite while loop, so, I am trying to create a function that kills whatever number of processes are generated by that above function. I tried stuff like
x.terminate()
But that just does not work, I think that should kill all the sub-processes, but it does not do that, I think it might be killing the last launched process or something along those lines, but my question is, how can I kill whatever number of processes launched by my first function?