From d80f2e271ceb79441f0737f77b1f805027cc87a2 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 14 Jul 2014 12:26:10 -0400 Subject: [PATCH] VBOX: Make sure we only check for the VM exit code if we have a valid handle. --- samples/vboxwrapper/vbox.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index f066dfb924..bcdd53334f 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -2059,12 +2059,14 @@ int VBOX_VM::get_vm_process_id() { } int VBOX_VM::get_vm_exit_code(unsigned long& exit_code) { -#ifndef _WIN32 +#ifdef _WIN32 + if (vm_pid_handle) { + GetExitCodeProcess(vm_pid_handle, &exit_code); + } +#else int ec = 0; waitpid(vm_pid, &ec, WNOHANG); exit_code = ec; -#else - GetExitCodeProcess(vm_pid_handle, &exit_code); #endif return 0; }