Skip to content

Instantly share code, notes, and snippets.

@ernestas-poskus
Created November 30, 2014 17:09
Show Gist options
  • Save ernestas-poskus/31fe6e42a34795b6d6bd to your computer and use it in GitHub Desktop.
Save ernestas-poskus/31fe6e42a34795b6d6bd to your computer and use it in GitHub Desktop.
PID of running process
package main
import (
"fmt"
"os"
)
func main() {
os.Create("a.txt")
argv := []string{"-f", "a.txt"}
files := []*os.File{nil, os.Stdout, os.Stderr}
attr := &os.ProcAttr{Dir: "./", Files: files}
pro, _ := os.StartProcess("/usr/bin/tail", argv, attr)
fmt.Println(pro.Pid)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment