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

process.PidExists() is inefficient, should only check given PID #607

Closed
Lomanic opened this issue Nov 12, 2018 · 1 comment · Fixed by #713
Closed

process.PidExists() is inefficient, should only check given PID #607

Lomanic opened this issue Nov 12, 2018 · 1 comment · Fixed by #713

Comments

@Lomanic
Copy link
Collaborator

Lomanic commented Nov 12, 2018

Instead of listing every processes and iterating over each of them it should use the OS capabilities to only check the given pid:

This might let us systematically check process existence at the beginning of every process function like Python psutil does/when an error is encountered, for better error messages. As discussed in #605 (comment)

Note: depending of the implementation, it might still be more efficient to keep the current "get all running processes and iterate over them" approach to check for PID existence, this should always be benchmarked.

@Lomanic
Copy link
Collaborator Author

Lomanic commented Nov 13, 2018

Looks like as simple as using os.FindProcess and process.Signal(syscall.Signal(0)), only problem is on Windows os.FindProcess doesn't do as many checks as Python psutil, so we will still need to redefine the same function in process/process_posix.go and process/process_windows.go (using syscalls there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant