Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用clone()时出现无效参数错误_C_Linux - Fatal编程技术网

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

使用clone()时出现无效参数错误,c,linux,C,Linux,我正在使用此函数调用clone() clone(fun,(char*)堆栈+0x500000,SIGCHLD | clone|u文件| clone|u FS,arg) 其中fun是一个函数:int fun(void*), stack=malloc(0x500000),arg的类型为void* 我想知道是什么原因导致了无效的论点 我已检查堆栈是否不为空。人工克隆: The child_stack argument specifies the location of the stack u

我正在使用此函数调用clone()

clone(fun,(char*)堆栈+0x500000,SIGCHLD | clone|u文件| clone|u FS,arg)

其中fun是一个函数:int fun(void*), stack=malloc(0x500000),arg的类型为void*

我想知道是什么原因导致了无效的论点

我已检查堆栈是否不为空。

人工克隆:

  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.

你检查过那堆东西了吗!=NULL?从
peror()
输出的“无效参数”与宏
EINVAL
对应的错误号相同。您是否阅读了
clone()
的手册页?它列举了产生这段代码的大量原因,但其中大多数都与特定的错误标志组合有关。不正确的是
child\u stack
参数为零(NULL)。请注意,
malloc()
失败时返回
NULL
。@socketpair I checked stack不是NULL。