如何在 QNX 中仅执行 1 次"top"(c++ 编程)

How to execute "top" only 1 time in QNX (c++ programming)

本文关键字:top c++ 编程 QNX 执行      更新时间:2023-10-16

我正在尝试为 QNX 编写简单的应用程序。我安装了 qnx momentics ide 并将其连接到 QNX 虚拟机,并尝试执行"top"命令

#include <cstdlib>
#include <iostream>
#include <process.h>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
    system("top");
    return EXIT_SUCCESS;
}

我正在获取并获取结果,直到我在 QNX 虚拟机中手动杀死"顶部"进程。但我只需要 1 次。有什么想法吗?

此页面建议您应该将system("top")更改为system("top -i 1")

top -i 1

是仅获取一次迭代的正确语法。 -n #用于节点计数。