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/svc/mgr: Documentation of args argument to CreateService incorrect. #20440
Comments
CL https://golang.org/cl/43714 mentions this issue. |
Distinct in what way? And so what? Why should we care?
Both args are passed to svc.Handler.Execute. That is the only "same" thing. Is that a problem?
Correct.
Maybe. I did not check. I do not understand what is the problem here. I suspect you are unhappy about some documentation. Which documentation is invalid and why? Thank you. Alex |
Hi Alex, The windows API call StartService takes some arguments, and these are passed to the windows API callback ServiceMain. (This is what the Go package makes available as the args parameter to svc.Handler.Execute.) When you register a service with the windows API call CreateService, you are allowed to include in lpBinaryPathName some command-line arguments. These get passed to the service's executable program as standard command line args (e.g. as "argv" to main()). Those two types of arguments are distinct. The Go package's Mgr.CreateService()'s args parameter is the second type; i.e. they are string appended to exepath:
This distinction caught me out because the doc comment for Mgr.CreateService implied its args parameter was the first type - "... args will be passed to svc.Handler.Execute". But, they won't be. (They're in os.Args.) Hope it's clear what I mean, it took me a while to work out what was happening yesterday while trying to pass some args to a service. (I'd already submitted a small doc fix CL which Brad merged before your comment.) thanks |
I was mistaken about that. Thank you for explaining. Alex |
No problem - this was a pretty minor thing overall. That the svc package exists and functions so well has been a huge boost to our project. Cheers. |
The "args" passed to Mgr.CreateService are distinct from the arguments passed to Service.Start (or via the "Start parameters" field in the service's Properties dialog box). The documentation implies they are the same. The args passed to Service.Start appear as the args on Svc.Handler.Execute, but the args passed to CreateService end up as command line arguments (os.Args).
I have a doc fix which I plan to submit as a way to learn the contribution process.
The text was updated successfully, but these errors were encountered: