一、execl()函数使用
1 #include<stdio.h>
2 #include<unistd.h>
3
4 int main()
5 {
6 printf("before execv \n");
7
8 if(execl("./newpro","pro","file3","file4",NULL) == -1){
9 perror("why");
10 }
11
12 printf("after execv \n");
13 return 0;
14 }
~
~
1 #include<stdio.h>
2 #include<unistd.h>
3
4 int main()
5 {
6 printf("before execv \n");
7
8 if(execl("./newpro","pro","file3","file4",NULL) == -1){
9 perror("why");
10 }
11
12 printf("after execv \n");
13 return 0;
14 }
~
~
~
二、输出系统时间
1 #include<stdio.h>
2 #include<unistd.h>
3
4 int main()
5 {
6 printf("before execv \n");
7
8 if(execl("/usr/bin/date","NULL",NULL) == -1){
9 perror("why");
10 }
11
12 printf("after execv \n");
13 return 0;
14 }
~
三、execlp()函数使用
不用pwd来查看绝对路径
已经修改了环境变量