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

Cannot find process with ID for UDP Endpoints #39

Closed
exploide opened this issue Nov 3, 2022 · 2 comments
Closed

Cannot find process with ID for UDP Endpoints #39

exploide opened this issue Nov 3, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@exploide
Copy link

exploide commented Nov 3, 2022

During the run of Invoke-UdpEndpointsCheck the following error occurs. The message is German but it means "Cannot find process with ID xyz".

+------+------------------------------------------------+------+
| TEST | NETWORK > UDP Endpoints                        | INFO |
+------+------------------------------------------------+------+
| DESC | List all UDP ports that are in a LISTEN state. For    |
|      | each one, the corresponding process is also returned. |
|      | DNS is filtered out to minimize the output.           |
+------+-------------------------------------------------------+
Get-Process : Es kann kein Prozess mit der Prozess-ID 55184 gefunden werden.
In Zeile:514 Zeichen:86
+ ... oteProperty" -Name "Name" -Value (Get-Process -PID $ProcessId).Proces ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (55184:Int32) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Commands.GetProcessCommand

So I assume either we have no privileges looking up the process, or the processes are so short living that they are gone when the process info is retrieved. However, listing TCP services works and it is always reproducible on this particular machine, so I'm a bit confused. Maybe this exception can be handled and the process name can be left empty in this case?

@itm4n
Copy link
Owner

itm4n commented Nov 3, 2022

Hello,

Thank you for reporting this issue.

I doubt this is a matter of privileges as Get-Process can be invoked even on protected processes for instance. A race condition between the time the ports are enumerated and the time the process is queried is possible but unlikely, especially as you are able to reproduce the issue reliably.

The behavior you are observing could be caused by a forking mechanism. The process that created the socket no longer exists, I don't know.

Whatever the reason, you are right, the script is missing some error handling. I will see how I can fix this.

Thanks again! :)

@itm4n itm4n added the bug Something isn't working label Nov 4, 2022
@itm4n
Copy link
Owner

itm4n commented Nov 7, 2022

Problem fixed, I simply added -ErrorAction SilentlyContinue to ignore errors in case the process associated to the TCP/UDP endpoint no longer exists.

Get-Process -PID $ProcessId -ErrorAction SilentlyContinue

@itm4n itm4n closed this as completed Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants