123456789101112131415161718192021222324252627282930313233 |
- #include <string.h>
- #include <unistd.h>
- int main()
- {
- int pid, pip[2];
- char instring[20];
- char * outstring = "Hello World!";
- pipe(pip);
- pid = fork();
- if (pid == 0)
- {
-
- close(pip[0]);
-
- write(pip[1], outstring, strlen(outstring));
-
- close(pip[1]);
- }
- else
- {
-
- close(pip[1]);
-
- read(pip[0], instring, 7);
-
- close(pip[0]);
- }
- }
|