Boost库子进程间消息队列通信问题

问题遇到的现象和发生背景

我目前使用boost库实现多进程通信,但是遇到了问题:1号进程使用消息队列发送结构体给2号进程,2号似乎能收到东西,但是怎么也打印不出收到的内容。

问题相关代码
pid_t pid = fork();
if(!pid){//1
    printf("sub pid 1\n");
    message_queue::remove("test");
    message_queue testmq(create_only, "test", 10, 50);
    mystuct hhhh;
    hhhh.s = "test";
    testmq.send(&hhhh, sizeof(hhhh), 0);
   exit(10);
}
pid = fork();
if(!pid){//1
    printf("sub pid 2\n");
    message_queue mq0(open_only,"test");
    mystuct tttt;
    unsigned int priority=0;
    unsigned long recvd_size=0;
    mq0.receive(&tttt, 50, recvd_size, priority);
    printf("receive success,size:%d\n",recvd_size);
    cout<<"sub:"<<tttt.s<<endl;
    exit(10);
}
运行结果及报错内容
sub pid 1
sub pid 2
receive success,size:40
sub:
我的解答思路和尝试过的方法

如果把发送内容放在主进程里2号进程就能收到。不知道有没有什么好的办法可以实现子进程之间的通信。

手动启动两个程序,不用fork再试试

hhhh.s="test“;
改为
strncpy(hhhh.s,"test",4);hhhh.s[4]=0;
前提是hhhh.s的声明为char s[一个大于等于5的数];