Skip to content

Instantly share code, notes, and snippets.

Created Mar 19, 2015
What would you like to do?
/* Creates fifo */
mkfifo(argv[1], S_IRWXU | S_IRWXG | S_IRWXO);
int fifo = open(argv[1], O_RDONLY);
/* Duplicate the file 'fifo', so that file descriptor 0 points to it.
* Note that 0 is the file descriptor of stdin. */
dup2(fifo, 0);
char line[1024];
int i = 0;
printf("Reading File %s\n", argv[1]);
while(fgets(line, 1024, stdin))
printf("%3d| %s", i++, line);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment