File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,12 +67,15 @@ mod inner {
6767
6868 #[ cfg( windows) ]
6969 pub fn interrupt ( pid : u32 ) -> io:: Result < ( ) > {
70- use windows_sys:: Win32 :: System :: Console :: { CTRL_C_EVENT , GenerateConsoleCtrlEvent } ;
70+ use windows_sys:: Win32 :: System :: Console :: { CTRL_BREAK_EVENT , GenerateConsoleCtrlEvent } ;
7171
72- // NOTE: This only works if the process is in a new process group
72+ // NOTE: After testing, it seems CTRL_BREAK_EVENT works in all cases (or all the ones I tried).
73+ // CTRL_C_EVENT didn't work when using the `ctrlc` crate, for example, which is my primary use case.
74+ // NOTE 2: This only works if the process is in a new process group. I had mixed results with this,
75+ // so I'm not sure if it's actually required, but in one case it broke Windows CI, so I'm leaving it in.
7376 // SAFETY: This is a standard Windows console function. Any number passed in is memory safe,
7477 // even if it impacts a process the user hadn't intended.
75- if unsafe { GenerateConsoleCtrlEvent ( CTRL_C_EVENT , pid) } != 0 {
78+ if unsafe { GenerateConsoleCtrlEvent ( CTRL_BREAK_EVENT , pid) } != 0 {
7679 Ok ( ( ) )
7780 } else {
7881 Err ( io:: Error :: last_os_error ( ) )
You can’t perform that action at this time.
0 commit comments