import RPi.GPIO as GPIO
# set pin 16 to input
oldButtonState1 = True
buttonState1 = GPIO.input(16)
if buttonState1 != oldButtonState1 and buttonState1 == False :
print "Button 2 pressed-what time is it?"
subprocess.call("papirus-clock", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
It works fine, but now the screen is busy and the papirus-clock process needs to be killed with sudo killall papirus-clock from the command line in an ssh session to do anything else. How can I put the sudo killall command into a python script? I'm using psutil (sudo apt-get install python-psutil) but I'm not sure it can work to terminate a root process in a python script.