Execute a program file.
int __fastcall__ exec (const char* progname, const char* cmdline);
execreplaces the currently running program by a new one. Calling
exec()is identical to calling
exit(), then loading and starting the program named in the first argument, passing the command line specified as second argument. Instead of an empty string, a
NULLpointer may be passed as second parameter. On success, the function does not return. On failure, -1 is returned and
errnocontains an error code.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- On most platforms, the function needs to copy a small stub loader to some memory area outside the program space. This may collide with other programs. See the platform specific docs on this.
- Because it is necessary to terminate the running program before the memory can be reused to load the new one, there is a high chance that the function may not be able to return on errors.
- The command line is passed to the new program in the same way as cc65 programs expect the command line. If the new program is not a cc65 generated program, it may not be able to read it.
- See also