简体   繁体   English

使用 clone() 时出现无效参数错误

[英]Invalid Argument error when using clone()

I'm using this function call to clone()我正在使用此函数调用 clone()

clone (fun, (char*)stack + 0x500000, SIGCHLD | CLONE_FILES | CLONE_FS, arg);

where fun is a function: int fun(void*), stack = malloc (0x500000), and arg is of type void*.其中 fun 是一个函数:int fun(void*),stack = malloc (0x500000),arg 是 void* 类型。

I'm wondering what are some other possible causes for Invalid Argument perror.我想知道无效参数错误的其他一些可能原因是什么。

I have checked stack is not NULL.我检查过堆栈不是 NULL。

man clone:人克隆:

  The  child_stack  argument  specifies the location of the stack used by
   the child process.  Since the child and calling process may share  mem‐
   ory,  it  is  not possible for the child process to execute in the same
   stack as the calling process.  The calling process must  therefore  set
   up memory space for the child stack and pass a pointer to this space to
   clone().  Stacks grow downward on all processors that run Linux (except
   the  HP  PA  processors),  so child_stack usually points to the topmost
   address of the memory space set up for the child stack.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM