Situation:个
我想运行一个将其自身置于后台的命令.如果它使它更有可能,那么我将在前台运行该命令,并自己将其带到后台.
Question:
当进程在后台运行时:how can I get it's 100 using Go?
I tried the following:个
cmd := exec.Command("ssh", "-i", keyFile, "-o", "ExitOnForwardFailure yes", "-fqnNTL", fmt.Sprintf("%d:127.0.0.1:%d", port, port), fmt.Sprintf("%s@%s", serverUser, serverIP))
cmd.Start()
pid := cmd.Process.Pid
cmd.Wait()
这会立即返回,并让ssh
在后台运行.但是它的pid
不是正在运行的ssh
进程中的pid
.此外,它是父ssh
进程的pid
,在它Forking 和为自己设置背景之前.