File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed
src/coreclr/hosts/corerun Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Original file line number Diff line number Diff line change 1313#include < pinvoke_override.hpp>
1414#endif // TARGET_WASM
1515
16+ #ifdef TARGET_BROWSER
17+ #include < emscripten/emscripten.h>
18+ #endif // TARGET_BROWSER
19+
1620#include < fstream>
1721
1822#if defined(TARGET_UNIX)
@@ -363,6 +367,20 @@ static bool HOST_CONTRACT_CALLTYPE external_assembly_probe(
363367 return false ;
364368}
365369
370+ #ifdef TARGET_BROWSER
371+ bool is_node ()
372+ {
373+ return EM_ASM_INT ({
374+ if (typeof process !== ' undefined' &&
375+ process.versions &&
376+ process.versions .node ) {
377+ return 1 ;
378+ }
379+ return 0 ;
380+ });
381+ }
382+ #endif // TARGET_BROWSER
383+
366384static int run (const configuration& config)
367385{
368386 platform_specific_actions actions;
@@ -603,7 +621,14 @@ static int run(const configuration& config)
603621 actions.after_execute_assembly ();
604622 }
605623
606- #if !defined(TARGET_BROWSER)
624+ #ifdef TARGET_BROWSER
625+ if (!is_node ())
626+ {
627+ // In browser we don't shutdown the runtime here as we want to keep it alive
628+ return 0 ;
629+ }
630+ #endif // TARGET_BROWSER
631+
607632 int latched_exit_code = 0 ;
608633 result = coreclr_shutdown2_func (CurrentClrInstance, CurrentAppDomainId, &latched_exit_code);
609634 if (FAILED (result))
@@ -618,10 +643,6 @@ static int run(const configuration& config)
618643 ::free ((void *)s_core_libs_path);
619644 ::free ((void *)s_core_root_path);
620645 return exit_code;
621- #else // TARGET_BROWSER
622- // In browser we don't shutdown the runtime here as we want to keep it alive
623- return 0 ;
624- #endif // TARGET_BROWSER
625646}
626647
627648// Display the command line options
You can’t perform that action at this time.
0 commit comments