Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Pipes Example

From Wiki
Jump to: navigation, search
Article Metadata
Created: spark55 (01 Oct 2007)
Last edited: hamishwillee (27 Jul 2012)
How to communicate between two threads or processes#Pipes

The following code shows the creation and usage of Pipes(the code below follows the steps given in the above link):

#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
int pipefd[2];
unsigned int threadid;
// thread entry point
void* PipeWriterThread(void* arg)
char ch[32];
strcpy(ch, "abcd");
write(pipefd[1], ch, 4);
return NULL;
void CreateThreadL()
pthread_create(&threadid,(pthread_attr_t *)NULL,PipeWriterThread, NULL);
int main()
if(0 == pipe(pipefd))
char ch[128];
read(pipefd[0], ch, 10);
return 0;
This page was last modified on 27 July 2012, at 05:16.
113 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.