[netcore] Correctly send exit code to the caller
authorMarek Safar <marek.safar@gmail.com>
Thu, 26 Sep 2019 11:57:42 +0000 (13:57 +0200)
committerMarek Safar <marek.safar@gmail.com>
Thu, 26 Sep 2019 18:59:50 +0000 (20:59 +0200)
Commit migrated from https://github.com/mono/mono/commit/8da9eebcc6cc2f0dbdb75f88ee48ecb682b68771

src/mono/mono/mini/main-core.c

index 181c7fd..16803d5 100644 (file)
@@ -6,6 +6,7 @@
 #include "mini-runtime.h"
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/assembly-internals.h>
+#include <mono/metadata/environment.h>
 #include <mono/metadata/loader-internals.h>
 #include <mono/utils/mono-logger-internals.h>
 
@@ -281,6 +282,8 @@ int STDAPICALLTYPE coreclr_execute_assembly (void* hostHandle, unsigned int doma
        *ptr = NULL;
 
        mono_parse_env_options (&mono_argc, &mono_argv);
+
+       // TODO: Should be return code of Main only (mono_jit_exec result)
        *exitCode = mono_main (mono_argc, mono_argv);
 
        return 0;
@@ -292,6 +295,7 @@ int STDAPICALLTYPE coreclr_execute_assembly (void* hostHandle, unsigned int doma
 // Parameters:
 //  hostHandle              - Handle of the host
 //  domainId                - Id of the domain 
+//  latchedExitCode         - Latched exit code after domain unloaded
 //
 // Returns:
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
@@ -307,6 +311,8 @@ int STDAPICALLTYPE coreclr_shutdown_2 (void* hostHandle, unsigned int domainId,
        trusted_platform_assemblies = NULL;
        mono_core_trusted_platform_assemblies_free (a);
 
+       *latchedExitCode = mono_environment_exitcode_get ();
+
        return 0;
 }