(C语言)如何使用exec函数族?
发布网友
发布时间:2022-05-07 04:53
我来回答
共1个回答
热心网友
时间:2023-10-16 01:46
函数名: exec...
功 能: 装入并运行其它程序的函数
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
char *envp[]);
int execlp(char *pathname, char *arg0, arg1, .., NULL);
int execple(char *pathname, char *arg0, arg1, ..., NULL,
char *envp[]);
int execv(char *pathname, char *argv[]);
int execve(char *pathname, char *argv[], char *envp[]);
int execvp(char *pathname, char *argv[]);
int execvpe(char *pathname, char *argv[], char *envp[]);
程序例:/* execv example */
#include <process.h>
#include <stdio.h>
#include <errno.h>void main(int argc, char *argv[])
{
int i; printf("Command line arguments:\n");
for (i=0; i<argc; i++)
printf("[%2d] : %s\n", i, argv[i]); printf("About to exec child with arg1 arg2 ...\n");
execv("CHILD.EXE", argv); perror("exec error"); exit(1);
}
热心网友
时间:2023-10-16 01:46
函数名: exec...
功 能: 装入并运行其它程序的函数
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
char *envp[]);
int execlp(char *pathname, char *arg0, arg1, .., NULL);
int execple(char *pathname, char *arg0, arg1, ..., NULL,
char *envp[]);
int execv(char *pathname, char *argv[]);
int execve(char *pathname, char *argv[], char *envp[]);
int execvp(char *pathname, char *argv[]);
int execvpe(char *pathname, char *argv[], char *envp[]);
程序例:/* execv example */
#include <process.h>
#include <stdio.h>
#include <errno.h>void main(int argc, char *argv[])
{
int i; printf("Command line arguments:\n");
for (i=0; i<argc; i++)
printf("[%2d] : %s\n", i, argv[i]); printf("About to exec child with arg1 arg2 ...\n");
execv("CHILD.EXE", argv); perror("exec error"); exit(1);
}
热心网友
时间:2023-10-16 01:46
函数名: exec...
功 能: 装入并运行其它程序的函数
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
char *envp[]);
int execlp(char *pathname, char *arg0, arg1, .., NULL);
int execple(char *pathname, char *arg0, arg1, ..., NULL,
char *envp[]);
int execv(char *pathname, char *argv[]);
int execve(char *pathname, char *argv[], char *envp[]);
int execvp(char *pathname, char *argv[]);
int execvpe(char *pathname, char *argv[], char *envp[]);
程序例:/* execv example */
#include <process.h>
#include <stdio.h>
#include <errno.h>void main(int argc, char *argv[])
{
int i; printf("Command line arguments:\n");
for (i=0; i<argc; i++)
printf("[%2d] : %s\n", i, argv[i]); printf("About to exec child with arg1 arg2 ...\n");
execv("CHILD.EXE", argv); perror("exec error"); exit(1);
}