Created
November 24, 2014 10:54
-
-
Save suchasplus/b17e1ee73f28b29e2174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <limits.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
int main(void) | |
{ | |
char c = 'c'; | |
int i; | |
const char *fifo = "/tmp/testforfifobuf"; | |
fprintf(stdout, "Fifo Creation\n"); | |
mkfifo(fifo, 0777); | |
struct stat _st; | |
int ret = stat(fifo, &_st); | |
if(ret != 0) { | |
fprintf(stdout, "Fifo Creation Failed, Exit!\n"); | |
return -1; | |
} | |
fprintf(stdout, "Theoretical max size: %d\n", PIPE_BUF); | |
int fifo_fd = open(fifo, O_RDWR | O_NONBLOCK); | |
fprintf(stdout, "Writing in fifo\n"); | |
for(i=0;; i++) | |
{ | |
if( write(fifo_fd, &c, 1) == -1) | |
{ | |
perror("Write"); | |
_exit(1); | |
} | |
fprintf(stdout, "%d bytes written\n", i+1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment