Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 19, 2015 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/c7373d8e5547a6936249 to your computer and use it in GitHub Desktop.
Save lettergram/c7373d8e5547a6936249 to your computer and use it in GitHub Desktop.
/* 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);
printf("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment