#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main() {
int res = system("ps ax -o pid -o command | grep sudoku | grep gnome > /dev/null");
printf("res = %d \n", res);
return 0;
}
我想通过检查system()
的返回码(或任何其他调用)来查看sudoku
是否正在运行。我不希望在任何地方打印输出。
我阅读了man page,但仍无法完全理解system()
的返回码。
无论sudoku
是否在运行,我都会得到res = 0
。
grep -e"[s]udoku"
。 - nmichaels