mirror of
https://github.com/Hizenberg469/Inter-Process-Communication-IPC-.git
synced 2026-04-19 18:02:24 +03:00
23 lines
414 B
C
23 lines
414 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
int pfds[2];
|
|
char buf[30];
|
|
|
|
if (pipe(pfds) == -1) {
|
|
perror("pipes");
|
|
exit(1);
|
|
}
|
|
|
|
printf("writing to file descriptor #%d\n", pfds[1]);
|
|
write(pfds[1], "test", 5);
|
|
printf("reading from file descriptor #%d\n", pfds[0]);
|
|
read(pfds[0], buf, 5);
|
|
printf("read \"%s\"\n", buf);
|
|
|
|
return 0;
|
|
} |