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

x/sys/windows: return more information from Query #25655

Closed
pytimer opened this issue May 31, 2018 · 7 comments
Closed

x/sys/windows: return more information from Query #25655

pytimer opened this issue May 31, 2018 · 7 comments

Comments

@pytimer
Copy link

@pytimer pytimer commented May 31, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64

What did you do?

I want to use sys/windows/svc/mgr Query() get the specifed service info

What did you expect to see?

I hope it can return more additional info, such as Win32ExitCode, ServiceType. It is best to return service PID.

What did you see instead?

Now this function only return State and Accepts.

service PID should call QueryServiceStatusEx, but now Query() call QueryServiceStatus, i see windows api doc says QueryServiceStatus has been superseded by the QueryServiceStatusEx function.

So whether use QueryServiceStatusEx replace QueryServiceStatus in Query()?

@gopherbot gopherbot added this to the Unreleased milestone May 31, 2018
@ianlancetaylor ianlancetaylor changed the title x/sys: windows service Query() return more additional info x/sys/windows: return more information from Query May 31, 2018
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 31, 2018

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jun 2, 2018

@pytimer

I take it you want to add more fields to golang.org/x/sys/windows/svc.Status structure. Am I correct?

If so, you have to tell more. You have to explain what fields you want to add and why.

Thank you.

Alex

@pytimer
Copy link
Author

@pytimer pytimer commented Jun 2, 2018

Hi, @alexbrainman

Thanks for your reply. You are right, i want to add some fields to svc.Status.

Win32ExitCode i want to get the service exit code, then my program can do something according to it.

ServiceType, it tell me what type of the service.

ProcessId we can get service pid and then monitor this process. we also can get process information.

Have i explained clearly?If not, you tell me.

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jun 10, 2018

i want to add some fields to svc.Status.

svc.Status is populated from SERVICE_STATUS structure. For ProcessId we have to use SERVICE_STATUS_PROCESS instead. And service code in golang.org/x/sys/windows/svc uses SetServiceStatus to update service status. There is no SetServiceStatus alternative that takes SERVICE_STATUS_PROCESS instead of SERVICE_STATUS, so we cannot use SERVICE_STATUS_PROCESS in golang.org/x/sys/windows/svc .

The only way for you to get ProcessId is for us to change golang.org/x/sys/windows/svc/mgr.Query to return something different from svc.Status - perhaps create new Status struct in golang.org/x/sys/windows/svc/mgr with whatever fields required. If we do that, we would have to do the same to golang.org/x/sys/windows/svc/mgr.Control. This will brake existing programs, so we should not take this decisions lightly.

Alternatively you could just use golang.org/x/sys/windows/svc/mgr.Service.Handle and call whatever Windows function you want to get what you want.

What do you think?

Alex

@pytimer
Copy link
Author

@pytimer pytimer commented Jun 12, 2018

Thanks for your reply.

I understand what you mean, you are right.

If i want to more information, i will use golang.org/x/sys/windows/svc/mgr.Service.Handle and call Windows function.

Thanks again. :)

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jun 13, 2018

Thanks again. :)

No worries. I will close this issue. Please reopen, if there is something else to do here.

Alex

@pytimer
Copy link
Author

@pytimer pytimer commented Jun 13, 2018

OK! :)

@golang golang locked and limited conversation to collaborators Jun 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.