I'm trying to send a CTRL-C event to a java process started with exec.
cmd := exec.Command("javaw", "-cp", "burst.jar;conf", "brs.Burst")
cmd.Dir = burstCmdPath
cmd.Env = append(os.Environ())
err = cmd.Start()
...
cmd.Process.Signal(syscall.SIGINT)
Unfortunately, the SIGINT-signal does not work on windows. I do not want to KILL the process. I just want to close it gracefully with CTRL-C.
I tried several things:
- Calling taskkill: Process does only react to forced kill.
-
Using win32-API:
... d, err := syscall.LoadDLL("kernel32.dll") p, e := d.FindProc("GenerateConsoleCtrlEvent") r, _, e := p.Call(syscall.CTRL_C_EVENT, uintptr(cmd.Process.Pid)) if r == 0 { fmt.Print("GenerateConsoleCtrlEvent: %v ", e) } ...Does not throw any errors, but does not work either.
If you open burst.jar inside a shell, you can just press CTRL+C to signal a shutdown, but why not with exec? Any ideas?