Created
March 19, 2015 00:36
This file contains 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
/* 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