19/02/2017, 12:37
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
int main(int argc, char *argv[]){
pid_t pid;
int mypipefd[2];
int ret, ret2;
int dim_buffer = 100;
char buf[dim_buffer];
unsigned int alarm = 10;
ret = pipe(mypipefd);
if(ret == -1){
perror("pipe");
exit(1);
}
pid = fork();
if(pid == 0) {
while(1){
//CHILD PROCESS
read(mypipefd[0], buf, dim_buffer);
printf("|Child Process| stampa della frase: %s\n", buf);
}
} else {
//PARENT PROCESS
while(1) {
ret2 = read(0, buf, dim_buffer);
write(mypipefd[1], buf, dim_buffer);
}
}
return 0;
}
19/02/2017, 15:52
Skuola.net News è una testata giornalistica iscritta al Registro degli Operatori della Comunicazione.
Registrazione: n° 20792 del 23/12/2010.
©2000—
Skuola Network s.r.l. Tutti i diritti riservati. — P.I. 10404470014.
Powered by phpBB © phpBB Group - Privacy policy - Cookie privacy
phpBB Mobile / SEO by Artodia.