使用clone()时出现无效参数错误
我正在使用此函数调用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(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。