int32 ExecuteAsSubroutine(CodeHandle code,int32 argc, char **argv);
LoadCode()
. The code will run as a subroutine of the current task or thread. In order to function correctly, code being run as a subroutine should be linked with subroutinestartup.o instead of the usual cstartup.o.
The argc and argv parameters are passed directly to the main()
entry point of the loaded code. The return value of this function is the value returned by main()
of the code being run.
The values you supply for argc and argv are irrelevant to this function. They are simply passed through to the loaded code. Therefore, their meaning must be agreed upon by the caller of this function, and by the loaded code.
main()
function returns.
exit()
, the parent thread or task will exit, not just the subroutine code.
LoadCode
(), UnloadCode(), ExecuteAsThread()