1

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?

Comments
  • 0
    are 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
  • 0
    @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])
  • 0
    You 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 😊
  • 0
    @CptFox Thanks I'll look into that.
Add Comment