From c9ae0f69d87e64cd7d1839164cee172b27657b11 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 19 Nov 2016 11:14:11 +0100 Subject: vm: add ability to interrupt commands This is required for crash reproduction in manager. --- vm/gce/gce.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'vm/gce') 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() -- cgit mrf-deployment