Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <wait.h>
- #include <errno.h>
- #include <string.h>
- #include <unistd.h>
- extern int errno; //numer ostatniego błędu
- #define FIFO1 "/tmp/fifo.1"
- int main()
- {
- char buff[1024];
- int fifo;
- int flagi=O_RDONLY /*| O_NDELAY*/ ;
- if ((fifo = open(FIFO1, flagi)) < 0)
- perror("nie moze otworzyc fifo1 do pisania");
- int n=read(fifo,buff,sizeof(buff)); //fd jest deskryptorem czytanego pliku ,buf jest adresem struktory danych uzytkownika do ktorego wczytujemy dane ,count jest to liczba bajtow, ktore chce wczytac uzytkownik
- if (n<=0)
- perror("blad zapisu do fifo");
- else{
- buff[n]='\0';
- write(1,buff,n);
- printf("\n");
- }
- unlink(FIFO1); //usuniecie kolejki
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment