Debian Codegraph @

example/example.go

raw symbols SCIP
1 package main
2
3 import (
4 "fmt"
5 "strings"
6 "time"
7
8 "os"
9 "os/exec"
10
11 "github.com/erikdubbelboer/gspt"
12 )
13
14 func main() {
15 fmt.Println("HaveSetProcTitle:", gspt.HaveSetProcTitle)
16 fmt.Println("HaveSetProcTitleFast:", gspt.HaveSetProcTitleFast)
17
18 gspt.SetProcTitle("some title")
19
20 fmt.Println("The title has been set, 'ps a' now shows:")
21
22 out, err := exec.Command("ps", "aux").Output()
23 if err != nil {
24 // Could not execute 'ps'.
25 return
26 }
27 lines := strings.Split(string(out), "\n")
28 fmt.Println(lines[0])
29 for _, line := range lines {
30 if strings.Contains(line, "some title") {
31 fmt.Println(line)
32 }
33 }
34
35 fmt.Println("----")
36 fmt.Println("os.Environ() should still contain things like:")
37 fmt.Println("PATH =", os.Getenv("PATH"))
38
39 fmt.Println("----")
40 fmt.Println("os.Args should still be correct:")
41
42 for i, a := range os.Args {
43 fmt.Println(i, ":", a)
44 }
45
46 fmt.Println("----")
47 fmt.Println("You can now check the output of 'ps a' or 'top'.")
48 fmt.Println("Press Ctrl+C to kill this program.")
49
50 time.Sleep(time.Minute * 5)
51 }