c++ - 如何在linux中捕获超时的返回值
问题描述
谁能告诉我如何捕获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
以及如何打印错误。
解决方案
推荐阅读
- javascript - 样式/更改 Material UI React 中的自动完成关闭图标
- android - android:scaleType="centerInside" 在 androidx ConstraintLayout 中不受尊重?
- javascript - 如何在 Vue.js/Firebase 应用中显示时间戳
- docker - 将 docker 容器应用程序连接到远程数据库服务器
- javascript - 弧线显示射击游戏中剩余的重新加载时间
- graphql - 在 AWS AppSync 中访问 json 数组
- ruby-on-rails - 如何在 Rails 中启动 MidiSmtpServer
- html - 使用 prev next 滑块在中心获取轮播图像
- python - 用两个字符串制作一个情节
- three.js - ARAME/THREE 将物体放置在相机前面时考虑相机旋转