Advertisement
soulrpg

potoki1.c

Nov 6th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3.  
  4.  
  5. int main()
  6. {
  7.   int fd[2];
  8.   char buf[100];
  9.   pipe(fd);
  10.   if(fork()==0)
  11.     {
  12.       sleep(5);
  13.       write(fd[1], "Hello", 6);
  14.     }
  15.   else
  16.     {
  17.       // czeka na powrot z write
  18.       read(fd[0], buf, 6);
  19.       printf("%s\n", buf);
  20.     }
  21.   return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement