prctl
的原型是
int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5);
在man page中,而在header中,它被声明为可变函数:
extern int prctl (int __option, ...) __THROW;
unsigned long
?答案 0 :(得分:3)
只需传递你必须传递的内容,然后在其余参数中将{0}转换为unsigned long
或完全跳过它们。当prctl
被声明为可变函数时,它将相应地处理这种情况。
const char* name = "The user";
if (prctl(PR_SET_NAME, (unsigned long) name,
(unsigned long)0, (unsigned long)0, (unsigned long)0) == -1)
{
// handle error
perror("prctl failed");
return -1;
}
或
const char* name = "The user";
if (prctl(PR_SET_NAME, (unsigned long) name) == -1)
{
// handle error
perror("prctl failed");
return -1;
}