| 🛟 Updated. 28d5985 k33g 12h ago | 1 | //go:build !unix && !windows |
| 2 | |
| 3 | package tools |
| 4 | |
| 5 | import ( |
| 6 | "os" |
| 7 | "os/exec" |
| 8 | "syscall" |
| 9 | ) |
| 10 | |
| 11 | // shellProgram is a guess on a platform this package does not know. |
| 12 | func shellProgram() string { return "/bin/sh" } |
| 13 | |
| 14 | // shellArgs assumes a Bourne-style shell. |
| 15 | func shellArgs(command string) []string { return []string{"-c", command} } |
| 16 | |
| 17 | // childAttributes asks for nothing on a platform without process groups. |
| 18 | func childAttributes(*exec.Cmd, string) *syscall.SysProcAttr { return nil } |
| 19 | |
| 20 | // loneProcess is a command with nothing grouping what it started. |
| 21 | type loneProcess struct{ process *os.Process } |
| 22 | |
| 23 | // newGroup has no group to offer. |
| 24 | func newGroup(process *os.Process) group { return loneProcess{process: process} } |
| 25 | |
| 26 | // kill stops the process alone. |
| 27 | // |
| 28 | // Anything it started keeps running, and if that child holds the output pipe |
| 29 | // the run will not report itself finished until WaitDelay expires. That is the |
| 30 | // backstop rather than the intent; a platform-specific way to end a whole |
| 31 | // process tree would be the real answer here. |
| 32 | func (g loneProcess) kill() { _ = g.process.Kill() } |
| 33 | |
| 34 | func (loneProcess) release() {} |