BAR
BAR

Reputation: 17131

Cap'n Proto terminate called after throwing an instance of 'kj::ExceptionImpl'

When calling Cap'n Proto's writeMessageToFd(pipe, message); I get this error:

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

Upvotes: 0

Views: 781

Answers (1)

aho
aho

Reputation: 314

You've not really asked a question, but I can tell you from that exception that you shouldn't have attempted to call writeMessageToFd with an invalid file descriptor (the exception text tells you this "Bad file descriptor; fd = -1").

You have two options: - don't call that function if pipe == -1 (probably best, you should really have checked that the call which returned pipe didn't return -1) - surround your call to writeMessageToFd() with a try/catch and handle the exception appropriately

You should really go with the former and handle a -1 value in pipe appropriately.

Upvotes: 1

Related Questions