Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'cmd1 = psutil.Process(pid).cmdline()[0]' with IndexError: list index out of range #8

Open
zhaopan-vip opened this issue Oct 29, 2021 · 0 comments

Comments

@zhaopan-vip
Copy link

Exception:

File "... /pidfile/pidfile.py", line 29, in is_running
   cmd1 = psutil.Process(pid).cmdline()[0]
IndexError: list index out of range

This occurs when process been killed, with pidfile not removed...
Then next time run it, the exception happens...

Should we change the cmdline check with code below?

        try:
            cmdline = psutil.Process(pid).cmdline()
            if not cmdline:
                return False
            cmd1 = cmdline[0]
            return cmd1 == self._process_name
        except psutil.AccessDenied:
            return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant