2012年4月7日

有名管道

摘要: 写程序#include<stdio.h>#include<stdlib.h>#include<string.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>int main(){int f;int fd;//char buff[10];f = mkfifo("myfifo",06666);//创建有名管道char buf[] = "abcd";fd = open(& 阅读全文

posted @ 2012-04-07 22:57 小风儿_xf 阅读(469) 评论(0) 推荐(0) 编辑

无名管道pipe

摘要: #include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<string.h>int main(){pid_t pid;int pipefd[2];pipe(pipefd);pid = fork();if(pid == 0){//子进程char buf_2[20];bzero(buf_2, 20);sleep(2);read(pipefd[0], buf_2, 17);//从管道的读端读出数据printf("%s",buf_2);close(pipefd[0]); 阅读全文

posted @ 2012-04-07 20:43 小风儿_xf 阅读(193) 评论(0) 推荐(0) 编辑

进程

摘要: #include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<sys/wait.h>#include<sys/types.h>int main(){pid_t t;char buf[] = "test!";t = fork();//创建一个子进程 if(t == 0){printf("child\n");printf("C: %s\n",buf);execlp("ls","ls&quo 阅读全文

posted @ 2012-04-07 19:31 小风儿_xf 阅读(135) 评论(0) 推荐(0) 编辑

导航