I'm practicing process communication between parent process and 1 child. What I want to do is that every message that the child sends the parent reads it(some sort of blocking send, parent must read the message first before child continues to send another message). I can't use pipes. I've read on Silberschatz book about blocking send, but I haven't found a good example of it(maybe mailbox too). Any help would be nice! This is a piece of code:
int main(int argc, char** argv) {
printf("This process: ");
printf("%d\n",getpid());
printf("Parent: ");
printf("%d\n",getppid());
pid_t f;
int input;
f = fork();
if (f == 0) {
for(int i=0;i<5;i++){
printf("Input a number: ");
scanf("%d",&input);
send(getppid(),input);
}
printf("\n");
exit(0);
} else {
recv(f,input);
printf("%d",input);
}
wait();
exit(0);
}