Description
Hi,
On the legacy method WindowsServiceHelpers.IsWindowsService() the logic is based on SessionID == 0 and parent process services.exe.
Using services.exe seems enough, or in the worst case a OR condition on SessionID 0 or 1, but I guess the session is a safety guard in case of a third party software with an exe named services.exe.
The problem is on a windows container, services.exe has a sessionId = 1 and Golang framework steal the logic from this legacy method. So we experience issues with some Golang softwares hosted in docker and compatibles as cli + service. (Otelcollector, Windows exporter, and any other not launched as host process).
Any advice from the Microsoft team ?
Original code here : https://github.com/dotnet/extensions/blob/f4066026ca06984b07e90e61a6390ac38152ba93/src/Hosting/WindowsServices/src/WindowsServiceHelpers.cs#L31
Some details here : golang/go#56335 (comment)