|
|
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #define StreamFifo "test.mpg"
- int main()
- {
- int h_r, h_w, pid;
- unlink(StreamFifo);
- mkfifo(StreamFifo,0666);
- pid = fork();
- if(pid < 0){
- return -1;
- }else if(pid == 0){
-
- h_r = open(StreamFifo,O_RDONLY | O_CREAT | O_TRUNC | O_NDELAY);
- if(-1 == h_r)printf("read ");
- printf("hr = %d\n", h_r);
- }else{
- h_w = open(StreamFifo,O_WRONLY | O_CREAT | O_TRUNC | O_NDELAY);
- if(-1 == h_w)printf("write error\n ");
- if(ENXIO == errno)printf(" ENXIO\n");
- }
- return 0;
-
- }
复制代码 |
|