我交叉编译zmq
和czmq
ARM(arm-poky-linux
)构建PUB-SUB消息路由器。在这个程序中,我使用zthread_fork()
分叉了一个附加的线程,并通过管道进行交谈。当我在分叉后从主体做zstr_rcv()
时,我得到了分段错误。这段代码在我的Ubuntu中使用GCC工作得很好。我在这里做错了什么?还是ARM兼容性问题?ARM交叉编译的ZeroMQ zstr_rcv()给出了分段错误
下面是一个简单的代码片段。
// listener thread function.
static void listener_thread (void *args, zctx_t *ctx, void *pipe)
{
// Send sync message to main().
zstr_send (pipe, "READY");
// Do work.
while (1)
{
sleep (1);
}
}
// main() forks the listener thread and waits for the sync message from the listener with zstr_rcv().
int main (int argc, char **argv)
{
// Create a ZeroMQ context.
zctx_t *context = zctx_new();
assert (context);
// Deploy the listner.
void *listener = zthread_fork (context, listener_thread, NULL);
assert (listener);
// Wait for the sync signal.
char *string = zstr_recv (listener);
zstr_free (&string);
// Do stuff here.
while (1)
{
sleep (1);
}
return 0;
}
感谢您的快速响应。是的,我的不好,但这不是原因。我改变它使用'zstr_free',但仍然存在分段错误。 – fortytwo 2014-09-29 04:42:05
根据我的回答,这是我最后的一个大脑放屁。抱歉,添麻烦了。 – fortytwo 2014-09-29 07:20:04