File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 22
33package process
44
5- import "syscall"
5+ import (
6+ "os"
7+ "syscall"
8+ )
69
710var (
811 kernel32 = syscall .NewLazyDLL ("kernel32.dll" )
1316// On Windows, this uses GenerateConsoleCtrlEvent with CTRL_BREAK_EVENT
1417// because Go's p.Signal(os.Interrupt) is not implemented on Windows.
1518func SendInterrupt () {
16- // CTRL_BREAK_EVENT = 1
17- procGenerateConsoleCtrlEvent .Call (1 , 0 )
19+ // Send CTRL_BREAK_EVENT to current process's process group
20+ // Using os.Getpid() targets only processes in our group (typically just us in production)
21+ // This avoids sending to all console processes (group 0) which would kill parent processes
22+ pid := os .Getpid ()
23+ procGenerateConsoleCtrlEvent .Call (syscall .CTRL_BREAK_EVENT , uintptr (pid ))
1824}
You can’t perform that action at this time.
0 commit comments