[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


exec

Load and execute a child process within the current program memory.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32

Remark:

On the Macintosh, all exec family calls pass through exec(), because argument passing (argc, argv) doesn't exist for Mac application.

Prototype:
#include <unistd.h>
  
int exec(const char *path, ...);
int execl(const char *path, ...);
int execle(const char *path, ...);
int execlp(const char *path, ...);
int execv(const char *path, ...);
intexecve(const char *path, ...);
int excevp(const char *path, ...);

NOTE

For the MacOS, all exec-type calls pass through -exec(), because argument passing (argc, argv) doesn't exist for MacOS applications
Parameters:

Parameters for this facility are:

path  
const char *  
The commandline pathname to execute  
...  
 
A variable list of arguments  

The exec() type functions:

UNIX Function
On the Macintosh System
#define execl  
exec  
#define execv  
exec  
#define execle  
exec  
#define execve  
exec  
#define execlp  
exec  
#define execvp  
exec  

Launches the application named and then quits upon successful launch. Example of usage is given in "Example of exec() usage.."

Returns:

If successful exec() returns zero. If unsuccessful exec() returns negative one and sets errno according to the error.


NOTE

For the MacOS using SIOUX, these settings will automatically close the SIOUX program. The asktosaveonclose is kept at the default value to demonstrate that the original printf() statement is called however the second printf statement is not called.
See Also:

"Overview of SIOUX"

"Overview of errno.h"

Example of exec() usage.:
#include <stdio.h>
#include <SIOUX.h>
#include <unistd.h>


#define SIZE FILENAME_MAX
char appName[SIZE] = "Macintosh HD:SimpleText";

int main(void)
{ 
	SIOUXSettings.autocloseonquit = 1;
	SIOUXSettings.asktosaveonclose = 1;

	printf("Original Program\n");  
	exec(appName);
	printf("program terminated"); /* not displayed */

	return 0;
}

result
Display "Original Program"  
after the close of the program 
the SimpleText application is launched


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000