diff --git a/src/main.cpp b/src/main.cpp index 8405dc4..8e496ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,10 +107,11 @@ int main(int argc, char **argv) { std::cout << "Result: " << result.out << std::endl; - // Send the job id and result.out to sink - zmq::message_t reply(JOB_ID_LEN + result.out.size()); + // Send the job id, the exit code and result.out to sink + zmq::message_t reply(JOB_ID_LEN + sizeof(uint32_t) + result.out.size()); memcpy(reply.data(), jobId.data(), JOB_ID_LEN); - memcpy(static_cast(reply.data()) + JOB_ID_LEN, result.out.data(), result.out.size()); + sk::write_uint32(static_cast(reply.data()) + JOB_ID_LEN, result.exit_code); + memcpy(static_cast(reply.data()) + JOB_ID_LEN + sizeof(uint32_t), result.out.data(), result.out.size()); sender.send(reply, zmq::send_flags::none); } return 0; diff --git a/src/network.cpp b/src/network.cpp index d5d3a0c..d567639 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -2,4 +2,10 @@ namespace sk { uint32_t read_uint32(const char *buffer) { return static_cast(buffer[3]) | static_cast(buffer[2]) << 8 | static_cast(buffer[1]) << 16 | static_cast(buffer[0]) << 24; } +void write_uint32(char *buffer, uint32_t value) { + buffer[0] = static_cast(value >> 24); + buffer[1] = static_cast(value >> 16); + buffer[2] = static_cast(value >> 8); + buffer[3] = static_cast(value); +} } diff --git a/src/network.hpp b/src/network.hpp index db7ab6c..a577cef 100644 --- a/src/network.hpp +++ b/src/network.hpp @@ -4,4 +4,5 @@ namespace sk { uint32_t read_uint32(const char *buffer); +void write_uint32(char *buffer, uint32_t value); }