fix.修复Linux下的编译错误

This commit is contained in:
MistEO
2022-01-03 03:24:13 +08:00
parent 59bcb74260
commit 3a870d7831
6 changed files with 22 additions and 7 deletions

View File

@@ -61,6 +61,9 @@ asst::Controller::Controller()
#endif
m_pipe_buffer = std::make_unique<uchar[]>(PipeBuffSize);
if (!m_pipe_buffer) {
throw "controller pipe buffer allocated failed";
}
auto bind_pipe_working_proc = std::bind(&Controller::pipe_working_proc, this);
m_cmd_thread = std::thread(bind_pipe_working_proc);
@@ -447,11 +450,11 @@ std::pair<bool, std::vector<unsigned char>> asst::Controller::call_command(const
// parent process
// LogTraceScope("Parent process: " + cmd);
do {
ssize_t read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), BuffSize);
ssize_t read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), PipeBuffSize);
while (read_num > 0) {
pipe_data.insert(pipe_data.end(), m_pipe_buffer.get(), m_pipe_buffer.get() + read_num);
read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), BuffSize);
read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), PipeBuffSize);
};
} while (::waitpid(m_child, nullptr, WNOHANG) == 0);
}