Skip to content

Instantly share code, notes, and snippets.

@kotaroito
Created February 17, 2014 14:44
Show Gist options
  • Save kotaroito/9051869 to your computer and use it in GitHub Desktop.
Save kotaroito/9051869 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#define FIFO "fifo1"
int main(void)
{
FILE *fp;
int i;
char *str;
if (mkfifo(FIFO, 0644) < 0)
perror("mkfifo");
if ((fp = fopen(FIFO, "w")) == NULL)
perror("fopen");
str = calloc(0, 3);
for (i = 0; i < 26; i++) {
sprintf(str, "%c\n", 'a' + i);
fputs(str, fp);
}
fclose(fp);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment