Fix run as service detection #4002
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Fix run as a service detection on Windows. Instead of trying to detect if it is a service or not, for which both
svc.IsAnInteractiveSession()
andsvc.IsWindowsService()
are somehow broken, try to run as a Windows service, if it fails fallback to run as an interactive process. This will add a small cost, which on my machine is under 5 microseconds, to startup in the interactive mode compared to using theNO_WINDOWS_SERVICE
environment variable. While this value seems fine for startup I'm keeping theNO_WINDOWS_SERVICE
option instead of deprecating it (it doesn't seem worth the trouble of deprecating it).Link to Splunk idea:
N/A
Testing:
Added benchmark to measure the cost of trying to start as a service (notice that when running as a service there is no extra cost).
Documentation:
Added entry in changelog.