Next Previous Contents

3.86 exec

Function

Execute a program file.

Header

unistd.h

Declaration

int __fastcall__ exec (const char* progname, const char* cmdline);

Description

exec replaces 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 NULL pointer may be passed as second parameter. On success, the function does not return. On failure, -1 is returned and errno contains an error code.

Limits

  • 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.

Availability

cc65

See also

exit

Example

None.


Next Previous Contents