Open yuanpu90 opened 5 years ago
运行下下面的命令试试
unshare -m
记录一下:可能有新手和我一样在做5.1节时发现-d运行后子进程就没了,没有被init进程托管,这时可能是top命令出错了,可以先以-ti的形式进入程序,ls一下看看/proc文件夹下有没有东西,如果没有东西证明子进程执行top时会出错然后退出,这样ps -ef时自然是看不到子进程的.而如果和我一样在proc看不到东西的话可以检查一下setUpMount函数里面的syscall.Mount函数(挂载proc)有没有运行成功,只有这行运行成功后子进程跑top时才会运行成功.
您好 我的环境是centos7 go1.6.3 在运行code5-1时报了如下的错 请问怎么解决这个错误 [root@localhost mydocker]# ./mydocker run -d top {"level":"info","msg":"createTty false","time":"2019-04-17T19:13:21-07:00"} {"level":"error","msg":"fork/exec /proc/self/exe: no such file or directory","time":"2019-04-17T19:13:21-07:00"} panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x548036]
goroutine 1 [running]: main.Run(0x5a4b00, 0xc42004a630, 0x1, 0x1, 0xc4200584e0) /root/gocode/mydocker/run.go:26 +0x126 main.glob..func1(0xc42006c420, 0xc420088000, 0xc42006c420) /root/gocode/mydocker/main_command.go:57 +0x3f1 github.com/urfave/cli.HandleAction(0x56d880, 0x5ae0f0, 0xc42006c420, 0x0, 0xc42004c180) /home/mygo/src/github.com/urfave/cli/app.go:502 +0xbe github.com/urfave/cli.Command.Run(0x5a35e1, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5ad3d7, 0x51, 0x0, ...) /home/mygo/src/github.com/urfave/cli/command.go:165 +0x4bb github.com/urfave/cli.(*App).Run(0xc420080000, 0xc42000e080, 0x4, 0x4, 0x0, 0x0) /home/mygo/src/github.com/urfave/cli/app.go:259 +0x740 main.main() /root/gocode/mydocker/main.go:31 +0x17a