摘要:
#include "public.h"#define K 1024#define WRITELEN (128*K)int main(){int result=-1;int fd[2],nbytes;pid_t pid;char string[WRITELEN]="你好,管道";char readbuffer[10*K];int *write_fd=&fd[1];int *read_fd=&fd[0];result=pipe(fd);if (-1==result){printf("建立管道失败\n");return -1 阅读全文
摘要:
#include "public.h"int main(){int result=-1;int fd[2],nbytes;pid_t pid;char string[]="你好,管道";char readbuffer[80];int *write_fd=&fd[1];int *read_fd=&fd[0];result=pipe(fd);if (-1==result){printf("建立管道失败\n");return -1;}pid=fork();if (-1==pid){printf("fork 进程失败 阅读全文
摘要:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>int main(){int result=-1;//创建管道的结果int fd[2],nbytes;//文件描述符,字符个数pid_t pid;//文件描述符 1 用于写,文件描述符 0 用于读int *write_fd=&fd[1];//写文件描述符int *read_fd=&fd[0];//读文件描述符result =pi 阅读全文
摘要:
#include <stdio.h>#include <unistd.h>int main(){char *args[]={"/bin/ls",NULL};printf("系统分配的进程号是:%d\n",getpid());if (execve("/bin/ls",args,NULL)<0){printf("创建进程出错\n");}return 0;} 阅读全文