-
Notifications
You must be signed in to change notification settings - Fork 243
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
Refactor CRC shell detection mechanism to use process parent programatically #4562
Comments
I'd summarize this as
|
I modified getProcessEntry method to list all the processes that are included with the CreateToolhelp32Snapshot call by adding some debug statements. However, I'm not able to see shell processes in that list: rohan@rokumar-lenovo:~$ /mnt/c/Users/rokum/go/bin/crc.exe oc-env --log-level debug
DEBU CRC version: 2.45.0+291032
DEBU OpenShift version: 4.17.10
DEBU MicroShift version: 4.17.10
DEBU Running 'crc oc-env'
Process ID: 0, [System Process]
Process ID: 4, System
Process ID: 172, Secure System
Process ID: 232, Registry
Process ID: 720, smss.exe
Process ID: 1168, csrss.exe
Process ID: 1264, wininit.exe
Process ID: 1292, csrss.exe
Process ID: 1348, services.exe
Process ID: 1380, winlogon.exe
Process ID: 10016, wsl.exe I see that the process being listed is |
wsl is probably special, as it provides a linux virtual machine. There could be some mismatch in the APIs to use to walk process lists, the win32 APIs ( |
The changes in #4526 (especially sorting and getting latest process approach) are only applicable for WSL, Unix and Linux environments. I'm able to get the parent process approach working on Linux using these steps (it involved executing
Shall I proceed with this approach? |
Maybe https://pkg.go.dev/github.com/shirou/gopsutil/[email protected]/process provides all you need (walking the process list and getting their command line). I don't really like spawning external processes when we can avoid it, it is slow, depends on the user environment, text output needs to be parsed, good error reporting means more text parsing, ... |
@cfergeau : Thanks, I'm able to get it working with gopsutil library. I'll update Unix/Linux shell detection code to use this approach. |
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
…-org#4562) + Move parsing ps output and picking recent pid approach to shell_windows. It would only be used in case of WSL. + Instead of parsing ps output and picking up recent pid. Inspect parent process of current process and keep going up until we find a shell process. Pick that shell process as currently active shell. Signed-off-by: Rohan Kumar <[email protected]>
Description
Originally posted by @cfergeau in #4526 (comment)
Acceptance Criteria
The text was updated successfully, but these errors were encountered: