linux clone() returning -1 as child_pid
我有以下程序:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#define _GNU_SOURCE #include<sched.h> #include<stdio.h> #include<stdlib.h> #include<sys/wait.h> #include<unistd.h> static char child_stack[2048]; static int child_fn() { int main() { waitpid(child_pid, NULL, 0); |
我得到以下输出
1
2 |
# ./clone
clone()= –1 |
谁能帮我理解为什么会这样?
Note: I’m running this under a
docker image withubuntu:latest . Also notice that the prompt is# instead of$ , so does it have anything to do with the user who’s running this process, probablyroot in this case?
正如评论中提到的,我使用
所以要修复它,我所要做的就是使用
运行我的 docker 容器
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/269300.html