killing a rosrun process using python script
Hi, I am writing a GUI interface to run nodes in ROS. The following code execute a rosrun process when pressing Button1. I looked for a code in order to kill that process when pressing Button 2. I did not find something specific or related to this work.
#simple GUI
import os, time, signal, threading
from Tkinter import *
from subprocess import call
from subprocess import Popen
import subprocess
import numpy as np
import cv2
#from PIL import Image, ImageTk
from PIL import *
def f1():
subprocess.Popen(["rosrun", "package_name", "nodename"])
def f2():
// NEED CODE HERE
root.title("root")
root.geometry("500x500")
button1 = Button(root,text="CORE", bg="black", fg="white", width=25, padx = 20, command=f1)
button1.pack()
button2 = Button(root,text="CORE", bg="black", fg="white", width=25, padx = 20, command=f2)
button2.pack()
Have you tried just killing the opened process with normal functionality from the subprocess module?