Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/uio.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/stat.h>
- #include <time.h>
- #include <string.h>
- #include <stdbool.h>
- #define MSGLEN (16)
- void checker(bool exp, const char *usrmsg, const char *file, const char *func, const int line){
- if(!(exp)){
- perror(usrmsg);
- fprintf(stderr, "%s %s %d\n", file, func, line);
- exit(EXIT_FAILURE);
- }
- }
- #define osAssert(exp, usrmsg) checker(exp, usrmsg, __FILE__, __func__, __LINE__);
- int main(int argc, char **argv){
- osAssert(2 == argc, "nema dovoljno argumenara");
- mode_t oldMask = umask(0);
- osAssert(-1 != mkfifo(argv[1], 0600), "make fifo failed");
- int fd = open(argv[1], O_WRONLY);
- osAssert(-1 != fd, "open failed");
- srand(time(NULL));
- char buf[MSGLEN];
- do{
- sprintf(buf, "%d", rand());
- osAssert(-1 != write(fd, buf, MSGLEN), "error write");
- printf("hocete jos? ");
- scanf("%s", buf);
- } while (!strcasecmp("da",buf));
- umask(oldMask);
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement