(pid int)
| 1037 | } |
| 1038 | |
| 1039 | func getProcessGroupID(pid int) (int, error) { |
| 1040 | statusPath := filepath.Join("/proc", strconv.Itoa(pid), "status") |
| 1041 | statusBytes, err := os.ReadFile(statusPath) |
| 1042 | if err != nil { |
| 1043 | return 0, err |
| 1044 | } |
| 1045 | |
| 1046 | status := string(statusBytes) |
| 1047 | for _, line := range strings.Split(status, "\n") { |
| 1048 | if strings.HasPrefix(line, "NSpgid:") { |
| 1049 | return extractIDFromStatusLine(line), nil |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | return 0, nil |
| 1054 | } |
| 1055 | |
| 1056 | // extractIDFromStatusLine extracts the ID from a status line in the format "Key:\tValue". |
| 1057 | func extractIDFromStatusLine(line string) int { |
no test coverage detected