github.com/bazelbuild/bazel-watcher@v0.25.2/internal/ibazel/process_group/process_group.go (about) 1 // Copyright 2018 The Bazel Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Implements a platform-independent process group. In effect, this allows you 16 // to terminate an entire tree of processes in one go. On Linux, this uses the 17 // Process Group system. On Windows, this uses Job Objects. 18 // 19 // Most of the things you would normally do with an exec.Cmd are safe to do 20 // with the RootProcess() Cmd, with two exceptions: 21 // 22 // - You cannot call .Start() on it. Use ProcessGroup.Start() instead. Doing 23 // so will work on Linux but not Windows. 24 // - You should not change .SysProcAttr. 25 26 package process_group 27 28 import ( 29 "os/exec" 30 "syscall" 31 ) 32 33 // ProcessGroup represents a tree of processes that can be terminated 34 // simultaneously. 35 type ProcessGroup interface { 36 RootProcess() *exec.Cmd 37 Start() error 38 Signal(signum syscall.Signal) error 39 Wait() error 40 Close() error 41 CombinedOutput() ([]byte, error) 42 }