多进程可以加快大文拷贝的速率,利用fork,创建子进程进行多个进程同时处理拷贝任务。
/*************************************************************************
> File Name: project.c
> Author: xuchen_allen
> Mail: xuchen_allen@163.com
> Created Time: 2019年02月03日 星期日 10时35分47秒
************************************************************************/
#include<stdio.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/wait.h>
#include<string.h>
int main(int argc,char*argv[])
{
struct stat infor;
int fd,fd_copy;
//创建一个接受拷问数据的文件:
fd_copy=open("copy_test",O_RDWR|O_CREAT|O_TRUNC,0644);
if(fd_copy<0){
perror("open copy fail");
exit(1);
}
if(argc<2){
perror("worng");
exit(1);
}
fd = open(argv[1],O_RDONLY);
if(fd<0){
perror("open fail"