Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <unistd.h>
- #define MAX_BUF 1024
- int main()
- {
- int fd;
- char buf[MAX_BUF];
- char * myfifo = "/tmp/myfifo";
- /* create the FIFO (named pipe) */
- mkfifo(myfifo, 0666);
- /* write message to the FIFO */
- fd = open(myfifo, O_WRONLY);
- write(fd, "Luke, to ja jestem twoim ojcem!", sizeof("Luke, to ja jestem twoim ojcem!"));
- close(fd);
- wait(NULL);
- fd = open(myfifo, O_RDONLY);
- read(fd, buf, MAX_BUF);
- printf("Odebrano: %s\n", buf);
- close(fd);
- /* remove the FIFO */
- unlink(myfifo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement