July 2019
Intermediate to advanced
458 pages
12h 12m
English
Once the command has started its execution, synchronously or not, the underlying os.Process gets populated and it is possible to see its PID, as we can see in the following example:
package mainimport ( "fmt" "os/exec")func main() { cmd := exec.Command("ls", "-l") if err := cmd.Start(); err != nil { fmt.Println(err) return } fmt.Println("Cmd: ", cmd.Args[0]) fmt.Println("Args:", cmd.Args[1:]) fmt.Println("PID: ", cmd.Process.Pid) cmd.Wait()}
Read now
Unlock full access