Skip to content

Instantly share code, notes, and snippets.

Created Mar 19, 2015
What would you like to do?
int pfds[2];
int SIZE = 30;
char buf[SIZE];
char * msg = "This is a pipe example!";
/** Generates two pipe file descriptors **/
/** writer **/
if (!fork()) {
printf(" CHILD: writing to pipe\n");
write(pfds[1], msg, SIZE);
printf(" CHILD: exiting\n");
/** reader **/
printf("PARENT: reading from pipe\n");
read(pfds[0], buf, SIZE);
printf("PARENT: read \"%s\"\n", buf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment