-
Notifications
You must be signed in to change notification settings - Fork 292
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
Can't call GenerateConsoleCtrlEvent system call in windows containers #3173
Comments
@StefanScherer @mattn is this something you have encountered before? @mattn, I was liberally borrowing your idea from https://github.com/mattn/goemon/blob/master/proc_windows.go. If anyone has a better suggestion on where to post this, I'd welcome it! |
FYI, if you want to terminate process tree forcibly, you can use CreateJobObject/TerminateJobObject. |
Thanks @mattn, the thing I wanted most was to be able to intercept a signal and do a graceful shutdown with some cleanup. Ctrl-c and Ctrl-break seem like the only practical ways to do that? |
Yes. As far as I know, if you want to do graceful shutdown, GenerateConsoleCtrlEvent is only way to do. |
Darn, yeah that is the conclusion I've come to after the long journey I've been on too. Thanks for all your trailblazing on this front! |
Any suggestions on where I might file this bug to get to some windows container folks that would know the answer @mattn? |
@lox have you tried Windows Server 2019? It is fixed in the ltsc2019 image. I put your example code here and added a Dockerfile FROM golang:1.11.4
COPY testctrlc.go testctrlc.go
RUN go build testctrlc.go
CMD [ "testctrlc.exe" ] When I build and run the image on a Windows Server 2016 I can reproduce the error:
When I build and run the image on a Windows Server 2019 it works:
Thanks @taylorb-microsoft and team for yet another improvement in Windows Server 2019 :-) |
Thanks very much for that @StefanScherer! I'll try that image! |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
ping |
I can confirm this works in |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Expected behavior
When starting a process in a windows docker container, it's expected that the process should be able to call GenerateConsoleCtrlEvent to send CTRL_C or CTRL_BREAK events to it's own console process group and sub-processes.
This technique is used to signal subprocesses to gracefully terminate, e.g clean up resources before the stop.
Actual behavior
Any call to
GenerateConsoleCtrlEvent
returnsIncorrect function
.Information
Windows version: Windows 10 Pro: Version 10.0.17134.472
Docker for Windows: 2.0.0.0-win81 (29211)
Steps to reproduce the behavior
Dockerfile:
Tested with golang 1.11.4:
Output is:
Expected (as when run from outside docker):
The text was updated successfully, but these errors were encountered: