Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz dwa niezale ż ne programy, które b ę d ą się komunikowa ł y przy pomocy
- kolejki FIFO. Zadanie wykonaj w dwóch wariantach, tak jak zadanie 4. Po
- zako ń czeniu komunikacji kolejk ę nale ż y usun ąć .
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #define SOME_MESSAGE "Wiadomosc..."
- #define FIFO_DIR "./fifo"
- int main(void)
- {
- int fd;
- if(mkfifo(FIFO_DIR, 0600) == -1){
- perror("mkfifo");
- return EXIT_FAILURE;
- }
- if((fd = open(FIFO_DIR, O_WRONLY)) == -1){
- perror("open");
- return EXIT_FAILURE;
- }
- if(write(fd, SOME_MESSAGE, strlen(SOME_MESSAGE)) == -1){
- perror("write");
- return EXIT_FAILURE;
- }
- if(close(fd) == -1){
- perror("close");
- return EXIT_FAILURE;
- }
- if(unlink(FIFO_DIR) == -1){
- perror("unlink");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment