MCPcopy
hub / github.com/keploy/keploy / getProcessGroupID

Function getProcessGroupID

utils/utils.go:1039–1054  ·  view source on GitHub ↗
(pid int)

Source from the content-addressed store, hash-verified

1037}
1038
1039func 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".
1057func extractIDFromStatusLine(line string) int {

Callers 1

uniqueProcessGroupsFunction · 0.85

Calls 1

extractIDFromStatusLineFunction · 0.85

Tested by

no test coverage detected