exec 函数示例
来源:互联网 发布:淘宝少儿坎肩演出服装 编辑:程序博客网 时间:2024/06/06 15:44
execv.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
extern char **environ;
void main(int argc, char* argv[]){
printf("In execv func.\n");
execv("linuxdba",argv); //跳转去执行linuxdba程序
printf("Should do not execute.\n"); // execv执行成功,此句不会被执行
}
linuxdba.c
#include <stdio.h>
#include <unistd.h>
void main(){
sleep(3);
printf("This is in linuxdba func.\n");
}
execlp.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
extern char **environ;
void main(int argc, char* argv[]){
execlp("/bin/cat", "cat", argv[1], (char *)NULL);
}
gcc –o execlp execlp.c
./execlp /etc/passwd
execlp() 执行文件,并将第二个参数作为此执行文件的参数文件,参数必须以字符型空指针来结尾,以结束。
- exec 函数示例
- Linux的exec族函数使用示例
- exec函数
- exec 函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec函数
- exec 函数
- exec函数
- exec函数
- 深入Lucene索引机制
- 第13周项目2--Fibnacci 序列(递归)
- Enet入门(译)
- ?????
- 继承的赋值
- exec 函数示例
- 声明:本博客之前从另外我一个博客系统导入了大量博文,
- opacity通用解决方案
- HDU-1518 Square 搜索
- 华为面试题解析 - 07
- ntp修改时间
- 为DWR添加CDI支持
- android语音识别方法
- KM && zkw_flow