Namespaces

Variants
Actions

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.

Exemplos de pipes

From Wiki
Jump to: navigation, search
Article Metadata

Artigo
Tradução:
Originado de Pipes Example
Por kyllercg
Última alteração feita por hamishwillee em 09 Dec 2011



Pipes (dutos)

O código a seguir mostra como criar e usar pipes.

#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
 
int pipefd[2];
unsigned int threadid;
 
// Início da thread
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];
CreateThreadL();
read(pipefd[0], ch, 10);
close(pipefd[1]);
close(pipefd[0]);
}
return 0;
}
This page was last modified on 9 December 2011, at 04:33.
175 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.

×