系统编程之进程管理 execl

来源:互联网 发布:python 变量写入文件 编辑:程序博客网 时间:2024/05/02 01:27
#include<unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
    /*判断入参有没有传入文件名*/
    if(argc < 2)
    {
        perror("you haven't input the filename,please try again!\n");
        exit(EXIT_FAILURE);
    }
    /*调用execl函数,用于可执行程序touch替代本进程,除了进程号,都没有了*/
    if( execl("/bin/touch","touch",argv[1],NULL) < 0)
        perror("execl error!");
    return 0;
}
/* int execl(const char *path, const char *arg, ...);
*/
原创粉丝点击