-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use Job Objects and equivalent things on Mac/Linux #10
Comments
@gedw99 note, I'm that approach, but it doesn't seem to be sufficient. (https://github.com/loov/watchrun/blob/master/pgroup/kill_windows.go#L13) |
Can you say why and explain it ?? |
The issue is with subprocesses starting processes themselves and not chaining to the process group properly, so when you try to kill the process group the children won't be shutdown. Similarly, killing by PID can be problematic, because at the point of trying to kill, some other process may have started with the same PID (although, it's very unlikely). Similarly sending kill signal is notoriously in-effective on Windows, because processes can disregard that message. |
if you are the author of all the processes that watch run is trying to control you can handle those aspects - PIDS; signals If your not then it's harder to make sure they respect what the watchrun system is "telling them to do". Is that a fair statement ? |
Kind of. It's more of, the default process group / tree in Windows doesn't fully contain the children. i.e. it allows to detach subprocesses, so killing the tree doesn't kill them. But, yes, AFAIK, if they properly handle the process grouping themselves, then there should be less issues. |
well i call this progress :) We could make dummy services to refine those touchy areas - just to get the ball rolling and then also work through these things ? Also the dummy services would show others how to respect the signalling watchrun needs. |
Well, that seems more work than getting job objects etc. similar working. |
i guess i don't know the context of what Job Objects is meant to do etc ... could you explain or point me to it ? |
sure but the objective is monitoring ? give me the higher level reason for it. |
don't know if this helps: https://github.com/kolesnikovae/go-winjob |
The objective isn't monitoring, it's just to ensure that the process and all sub-processes get shutdown. And, yes, I'm aware that there are packages that implement winjob api. For Windows, I'll probably use https://pkg.go.dev/golang.org/x/sys/windows directly. Watchrun needs a small set of features, so directly using winapi should be sufficient. |
ok thats sounds wise too. |
Currently when starting things with
watchrun go run main.go
andmain.go
contains a server, thenwatchrun
doesn't automatically kill the subprocess. Which is not ideal. We can overcome this limitation by monitoring which subprocesses are created and then ensure they are killed as a whole.On Windows there are Job Objects, which allow such process groups that can be killed as a whole. The current approach for killing processes in Windows is rather hacky https://github.com/loov/watchrun/blob/master/pgroup/kill_windows.go#L19.
I'm not sure what the best approach on Unix is, but may be monitoring things with ptrace and capturing the pids?
The text was updated successfully, but these errors were encountered: