0

i need to stop a specific process(in the script that included) on command that is running in the background on my raspberry pi using python...what code should i use?

i tried different os commands but it didn't worked

path = "/home/pi/Desktop/fm_transmitter-master/"
os.chdir(path)
args = ["sudo", "python", "PiStation.py", "-f", "96", "song.mp3"]
pi_station = subprocess.Popen(args, stdout=subprocess.PIPE

i need to stop this procces on command using python code

beni_1234
  • 21
  • 6
  • 1
    Welcome to SO! How does `pi_station.terminate()` or `pi_station.kill()` work for you? Also, your code is truncated; did you use the `shell=True` or `shell=False` argument? – ggorlen Jun 15 '19 at 15:43
  • no i didnt used shell at all......this is all the code – beni_1234 Jun 15 '19 at 17:08
  • Well, this doesn't compile as is--at the very least, there's a missing closing paren. Let me know about `terminate()` and `kill()`, and if either of those work... – ggorlen Jun 15 '19 at 17:42
  • check this answer https://stackoverflow.com/questions/54522032/robust-way-to-manage-and-kill-any-process/56290192#56290192 – Siyavash vaez afshar Jun 16 '19 at 08:43

0 Answers0