diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-11-19 11:14:11 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-19 11:14:11 +0100 |
| commit | c9ae0f69d87e64cd7d1839164cee172b27657b11 (patch) | |
| tree | 5635ba71b0f51ad9487971b33e94a797aa994694 /vm/gce | |
| parent | 59f7c210d0584164a821bde6686debe169660f30 (diff) | |
vm: add ability to interrupt commands
This is required for crash reproduction in manager.
Diffstat (limited to 'vm/gce')
| -rw-r--r-- | vm/gce/gce.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 48d3da4c0..3e27989fa 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -146,7 +146,7 @@ func (inst *instance) Copy(hostSrc string) (string, error) { return vmDst, nil } -func (inst *instance) Run(timeout time.Duration, command string) (<-chan []byte, <-chan error, error) { +func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command string) (<-chan []byte, <-chan error, error) { conRpipe, conWpipe, err := vm.LongPipe() if err != nil { return nil, nil, err @@ -221,6 +221,10 @@ func (inst *instance) Run(timeout time.Duration, command string) (<-chan []byte, signal(vm.TimeoutErr) con.Process.Kill() ssh.Process.Kill() + case <-stop: + signal(vm.TimeoutErr) + con.Process.Kill() + ssh.Process.Kill() case <-inst.closed: signal(fmt.Errorf("instance closed")) con.Process.Kill() |
