9fans.net/go@v0.0.5/acme/Watch/sig_unix.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build linux darwin freebsd netbsd openbsd solaris 6 7 package main 8 9 import ( 10 "os/exec" 11 "syscall" 12 "time" 13 ) 14 15 func isolate(cmd *exec.Cmd) { 16 cmd.SysProcAttr = &syscall.SysProcAttr{ 17 Setpgid: true, 18 } 19 } 20 21 func quit(cmd *exec.Cmd) { 22 pid := cmd.Process.Pid 23 if pid <= 0 { 24 return 25 } 26 syscall.Kill(-pid, syscall.SIGQUIT) 27 } 28 29 func kill(cmd *exec.Cmd) { 30 pid := cmd.Process.Pid 31 if pid <= 0 { 32 return 33 } 34 syscall.Kill(-pid, syscall.SIGINT) 35 time.Sleep(100 * time.Millisecond) 36 syscall.Kill(-pid, syscall.SIGTERM) 37 time.Sleep(100 * time.Millisecond) 38 syscall.Kill(-pid, syscall.SIGKILL) 39 }