diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-02-02 20:21:38 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-02-02 20:23:40 +0100 |
| commit | 355865377102649df438e5d9dc7aa6d2a09bf7fc (patch) | |
| tree | b04295b486da771a0d0d2618fa27a5eaf69dfb0b /vm/gce | |
| parent | b9371a610178a570b770473c9654d1569cc00cee (diff) | |
vm: properly detect when a program exits
syz-fuzzer never exits (normally) so this does not affect syz-manager.
But during reproduction we can run a short running program (no repeat mode)
and currently VMs treat premature exit as an error.
Properly detect when a program exits and let callers decide what to do with it.
Diffstat (limited to 'vm/gce')
| -rw-r--r-- | vm/gce/gce.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go index edce6c38e..364a44f29 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -214,13 +214,24 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin case <-inst.closed: signal(fmt.Errorf("instance closed")) case err := <-merger.Err: - // Check if the instance was terminated due to preemption or host maintenance. - time.Sleep(5 * time.Second) // just to avoid any GCE races - if !GCE.IsInstanceRunning(inst.name) { - Logf(1, "%v: ssh exited but instance is not running", inst.name) - err = vm.TimeoutErr + con.Process.Kill() + ssh.Process.Kill() + merger.Wait() + con.Wait() + if cmdErr := ssh.Wait(); cmdErr == nil { + // If the command exited successfully, we got EOF error from merger. + // But in this case no error has happened and the EOF is expected. + err = nil + } else { + // Check if the instance was terminated due to preemption or host maintenance. + time.Sleep(5 * time.Second) // just to avoid any GCE races + if !GCE.IsInstanceRunning(inst.name) { + Logf(1, "%v: ssh exited but instance is not running", inst.name) + err = vm.TimeoutErr + } } signal(err) + return } con.Process.Kill() ssh.Process.Kill() |
