File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed
product-mini/platforms/posix Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ app_instance_main(wasm_module_inst_t module_inst)
8686 wasm_application_execute_main (module_inst , app_argc , app_argv );
8787 if ((exception = wasm_runtime_get_exception (module_inst )))
8888 printf ("%s\n" , exception );
89- return NULL ;
89+ return exception ;
9090}
9191
9292static void *
@@ -96,7 +96,7 @@ app_instance_func(wasm_module_inst_t module_inst, const char *func_name)
9696 app_argv + 1 );
9797 /* The result of wasm function or exception info was output inside
9898 wasm_application_execute_func(), here we don't output them again. */
99- return NULL ;
99+ return wasm_runtime_get_exception ( module_inst ) ;
100100}
101101
102102/**
@@ -643,14 +643,29 @@ main(int argc, char *argv[])
643643 }
644644#endif
645645
646- if (is_repl_mode )
646+ ret = 0 ;
647+ if (is_repl_mode ) {
647648 app_instance_repl (wasm_module_inst );
648- else if (func_name )
649- app_instance_func (wasm_module_inst , func_name );
650- else
651- app_instance_main (wasm_module_inst );
649+ }
650+ else if (func_name ) {
651+ if (app_instance_func (wasm_module_inst , func_name )) {
652+ /* got an exception */
653+ ret = 1 ;
654+ }
655+ }
656+ else {
657+ if (app_instance_main (wasm_module_inst )) {
658+ /* got an exception */
659+ ret = 1 ;
660+ }
661+ }
652662
653- ret = 0 ;
663+ #if WASM_ENABLE_LIBC_WASI != 0
664+ if (ret == 0 ) {
665+ /* propagate wasi exit code. */
666+ ret = wasm_runtime_get_wasi_exit_code (wasm_module_inst );
667+ }
668+ #endif
654669
655670#if WASM_ENABLE_DEBUG_INTERP != 0
656671fail4 :
You can’t perform that action at this time.
0 commit comments