任何人都可以告诉我如何捕获timeout
实用程序的输出。
正如我在下面所捕获的那样,但它没有达到预期的效果。
std::string syscommand = "timeout -s KILL 1s command";
int res = system(syscommand.c_str());
std::cout << res;
由于我经历了一些帖子,我发现输出应该如下所示。
124 if command times out
125 if timeout itself fails
126 if command is found but cannot be invoked
127 if command cannot be found
137 if command is sent the KILL(9) signal (128+9)
the exit status of command otherwise
以及如何打印错误。