
#4942: GHC.ConsoleHandler does not call back application when Close button is pressed -------------------------------------+------------------------------------- Reporter: Amatic | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: GHC API | Version: 6.12.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: Incorrect result | Test Case: at runtime | Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by pdedecker): I have an console application that communicates with external hardware (scientific instruments). This hardware needs to be initialized at application start and cleanly shut down at application end, otherwise damage or increased wear can result. Unfortunately, many users close the program by hitting the "X" close button on the console window, even when trained not to. Years of routine are hard to beat. This bug prevents me from solving this, by making it impossible to run safely shut down the equipment in response to a close event. Please make it possible to handle these events and run cleanup code. Regarding the possibility of the Haskell code leading to an unkillable window: google suggests that the application will be terminated after a timeout, even if the handler function hasn't returned yet. So this may not be an issue in practice? (e.g. https://stackoverflow.com/questions/47041407/why-does-my-windows-console- close-event-handler-time-out) ALSO: the documentation for GHC.ConsoleHandler should reflect that Close events are ignored, which does not appear to be the case at present. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/4942#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler