Cap' n Proto在抛出' kj :: ExceptionImpl'的实例后被调用。

时间:2015-08-13 07:47:49

标签: c++ protocol-buffers capnproto

致电Cap' n Proto' writeMessageToFd(pipe, message);时出现此错误:

terminate called after throwing an instance of 'kj::ExceptionImpl'
  what():  src/kj/io.c++:323: failed: ::writev(fd, current, iov.end() - current): Bad file descriptor; fd = -1
stack: 0x7efead69cf89 0x7efead6a0c7f 0x7efead6a2648 0x7efead6a24f7 0x7efead8f40b7 0x7efead8f42a4 0x402c7b 0x402a36 0x4028df 0x7efeabd50e50 0x7efeabd5181a 0x7efeabd52669 0x7efeabd52a03 0x7efeabd52bb2 0x402865 0x4027ab

1 个答案:

答案 0 :(得分:1)

你没有真正问过一个问题,但我可以告诉你,你不应该试图用无效的文件描述符调用writeMessageToFd(异常文本告诉你这个“错误的文件描述符; fd = - 1" )。

您有两种选择:   - 如果管道== -1,请不要调用该函数(可能最好,你应该检查返回管道的调用没有返回-1)   - 用try / catch包围你对writeMessageToFd()的调用并适当地处理异常

你应该真的使用前者并在管道中适当处理-1值。