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

Cache Process Parent ID in Windows #948

Merged
merged 1 commit into from
Oct 11, 2020
Merged

Cache Process Parent ID in Windows #948

merged 1 commit into from
Oct 11, 2020

Conversation

AtakanColak
Copy link
Contributor

There is a parent field in process.Process, that is used as a buffer in process_linux.go but unused in process_windows.go code. As per #818, I wanted to make a suggestion to utilize it to cache ppid value which is returned in any getFromSnapProcess call.

This change will work only if we assume parent process ID won't change in Windows (and should it change, new value shouldn't be trusted).

@shirou
Copy link
Owner

shirou commented Oct 11, 2020

It works well, and I can not find any situation Parent ID changes (I am not familiar with Windows though).
And I think a cache is not good for library, application side should cache, but we already accepted a cache at #942, So I merge this.

Thank you for your contribution!

@shirou shirou merged commit fe68b86 into shirou:master Oct 11, 2020
@shirou
Copy link
Owner

shirou commented Oct 11, 2020

Note: I noticed #951 after merge this PR. so this PR perhaps same thread safe issue. Need to check.

@AtakanColak
Copy link
Contributor Author

@shirou yeah, totally forgot about race condition regarding #951 as it was write-once, I'll fix it tomorrow.

@AtakanColak AtakanColak deleted the windows-cache-ppid branch October 12, 2020 07:37
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

Successfully merging this pull request may close these issues.

2 participants