#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

typedef struct msgbuf {
	long mtype;
	char mtext[256];
} message_buf;

int main(void){

	int msqid;
	key_t key;
	message_buf rbuf;

	key = 1234;

	pid_t mypid, x;
	x=fork();
	mypid = getpid();
	if (x==0)
	{
		if ((msqid = msgget(key, 0666)) <0) {
			perror("msgrcv");
			exit(1);
		}
		printf(rbuf.mtext);
		exit(0);
	}
	else
	{
		printf("blabla2");
	}
	return 0;
}

Tak wyglada moj kod ktory ma odbierac wiadomosc w forku... nie wiem dlaczego nie dziala, podczas kompilowania g++ pojawia sie redefinition of struct msgbuf

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <string.h>

typedef struct msgbuf {
	long mtype;
	char mtext[256];
} message_buf;

int main(void){

int msqid;
int msgflg = IPC_CREAT | 0666;
key_t key;
message_buf sbuf;
size_t buf_length;
key = 1234;
if ((msqid = msgget(key, msgflg )) < 0){
	perror("msgget");
	exit(1);
}

sbuf.mtype = 1;
(void) strcpy(sbuf.mtext,  popen("df", "r"));
buf_length = strlen(sbuf.mtext) + 1;
}

Tutaj natomiast jest moj program ktory wysyla wiadomosc do tamtego drugiego i w chcialem zeby wysylal wywolanie popen("df", "r")... nie jestem dobry w te klocki dlatego prosze o pomoc.