Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
CptFox16166yare you sure the script is done running when you try to type ? try ctrl-C to stop it or ctrl-Z to place it in the background, see if you get back control
-
@CptFox Nope. Ctrl-C and Ctrl-Z don't work. I cannot type anything. Code looks like this:
import os
import psutil
import subprocess
import sys
procnames = ["retroarch", "emulationstation"]
for proc in psutil.process_iter():
if proc.name() in procnames:
pid = str(proc.as_dict(attrs=['pid'])['pid'])
name = proc.as_dict(attrs=['name'])['name']
pidkill = int(pid)
print("stopping... " + name + " (pid:" + pid + ")")
subprocess.call(["sudo", "kill", "-9", pid]) -
CptFox16166yYou could use the pkill command, that should do what this python is trying to do.
Too lazy yet to try to debug your code, try using a debugger to see where it hangs ? You should probably call as dict less, use the .name() and .pid directly, who knows, maybe it doesn't like being called multiple times.
But really, try pkill first, maybe "sudo pkill -f name", that really sounds like your usecase 😊
Related Rants
Ive got a weird issue with my raspberry pi script that doesn't let me type anything into the command line after the script runs.
I should explain I'm trying to write a script for retropie to load games from a script and to exit the current game from a script.
Anyone have any experience?
question
bash
raspberry pi
python