gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:46:15 24 4
gpt4 key购买 nike

我正在使用这个函数调用 clone()

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

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

我想知道无效参数错误的其他可能原因是什么。

我检查过堆栈不为 NULL。

最佳答案

人类克隆:

  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.

关于c - 使用 clone() 时出现无效参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36830097/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com