sysctl インターフェイスを介して別のプロセスの情報を取得しようとしています
int mib[4] = {0};
size_t len = sizeof( mib ) / sizeof( int );
struct kinfo_proc kp;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = 3027;
sysctl(mib, 4, &kp, &len, NULL, 0);
Error:
test.cpp: In function ‘int main(int, char**)’:
test.cpp:13:22: error: aggregate ‘main(int, char**)::kinfo_proc kp’ has incomplete type and cannot be defined
test.cpp:16:13: error: ‘KERN_PROC’ was not declared in this scope
よく見ましたが、決定的な答えはありませんでした。Linuxはシステム コールKERN_PROC
を介してサポートしますか。sysctl
ディストリビューション: Centos 6.2