我想获取文件PID_MAX
中存在的/sys/sys/proc.h
宏的值。
我当前的代码(main.c):
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h> /* type pid_t */
#include <sys/proc.h> /* macro PID_MAX */
#include <sys/unistd.h> /* function getpid, getppid */
/*
gcc -Wall -Wextra main.c -o main
./main
*/
int main ()
{
pid_t pidmax = PID_MAX;
printf ( "Value = %d\n", pidmax );
return 0;
}
返回以下错误:
error: 'PID_MAX' undeclared (first use in this function); did you mean 'UID_MAX'?
怎么可能?
恢复PID_MAX
的另一种方法?
[没有独立于平台的方法来检索最大pid值。例如,在Linux下,您可以通过/proc/sys
接口确定值]
$ sysctl kernel/pid_max
32768