(name string)
| 561 | } |
| 562 | |
| 563 | func FindPidByName(name string) []uint32 { |
| 564 | var pid_list []uint32 |
| 565 | content, err := util.RunCommand("sh", "-c", "ps -ef -o name,pid,ppid | grep ^"+name) |
| 566 | if err != nil { |
| 567 | Logger.Printf("warn, no running process of %s", name) |
| 568 | return pid_list |
| 569 | } |
| 570 | lines := strings.Split(content, "\n") |
| 571 | for _, line := range lines { |
| 572 | parts := strings.Fields(line) |
| 573 | value, err := strconv.ParseUint(parts[1], 10, 32) |
| 574 | if err != nil { |
| 575 | panic(err) |
| 576 | } |
| 577 | pid_list = append(pid_list, uint32(value)) |
| 578 | } |
| 579 | return pid_list |
| 580 | } |
| 581 | |
| 582 | // Execute adds all child commands to the root command and sets flags appropriately. |
| 583 | // This is called by main.main(). It only needs to happen once to the rootCmd. |
no test coverage detected