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

标签 c linux

我正在使用这个函数调用 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/

相关文章:

linux - 删除 linux 文件。 -rwsrwsrwt(可能是rootkit)

java - Linux 上的 JOGL 没有 glcontext 和 XInitThreads()

python - 如何在没有 .py 扩展名的情况下运行 argparse python 程序?

c - 如何计算旧内核上的自愿上下文切换

linux - 不能在算术表达式中使用乘法

c 编程 - 一位 parent 和 4 个 child 之间的双向沟通​​没有结果

c - 自动打印 C 中的结构和变量

c - OpenMP:并行程序并不比串行程序快(或不是非常快)。我究竟做错了什么?

c - #ifdef#else #endif 宏问题

c - 我的 program.exe 已停止工作