Skip to content

Instantly share code, notes, and snippets.

@alksl
Created November 29, 2013 13:23
Show Gist options
  • Save alksl/7705633 to your computer and use it in GitHub Desktop.
Save alksl/7705633 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char* argv[])
{
char c;
int fd;
FILE* file;
char * myfifo = "/tmp/myfifo";
mkfifo(myfifo, 0666);
freopen(myfifo, "r", stdin);
file = fopen(myfifo, "w");
fprintf(file, "Hello world\n");
fflush(file);
fclose(file);
do {
c = getc(stdin);
printf("%c",c);
} while( c != EOF);
unlink(myfifo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment