help on interprocess communication
bruey at cpsin2.cps.msu.edu
bruey at cpsin2.cps.msu.edu
Thu Feb 15 05:23:51 AEST 1990
Can any of you brainy netlanders give me a hint why this
doesn't work? I've been cursing at this code for days
and I can't get it to work. (I'm not even sure that the
forks are in the right order. So basically, I'm lost.)
#include<stdio.h>
main()
{
/* yes, I know I don't need all of these declarations, but
this isn't the only part of the program */
int pid;
int id1,id2,id3;
int rc=0,status,parent;
int filedes[2];
char *a,*buf1,*buf;
pipe(filedes);
if (fork())
{
printf("%d %d are filedes \n",filedes[0],filedes[1]);
buf = "first message";
write(filedes[1],buf,14);
if(fork())
{
read(filedes[1],buf1,14);
printf("in second %s \n",buf1);
}
}
}
More information about the Comp.lang.c
mailing list