I'm running a python script through cmd, that opens a new shell that runs a bash script. the problem is that I also need to kill it...
I've tried using subprocess.kill()
subprocess.terminate()
and even
os.system("taskkill /F /pid "+str(p.pid))
that gives back
SUCCESS: The process with PID 11508 has been terminated.
which didn't happen.
my code goes like this: the relevant python line is
p = Popen(['C:/cygwin64/bin/bash.exe', '-c', '. /etc/profile; /cygdrive/c/Users/user/Desktop/host_manager/ba.sh'], creationflags=CREATE_NEW_CONSOLE)
and ba.sh is
#! /bin/bash
`. /etc/profile`
/home/user/rc64_host_server.exe -in 50001 -out 50002 -d 1 -dsn 14993-0050
the exe is a ssh server that listens.
by the way, when I run
p = Popen('C:/cygwin64/bin/bash.exe', creationflags=CREATE_NEW_CONSOLE)
kill manages to do the job.
how can I kill the subprocess with the script??