MCPcopy Index your code
hub / github.com/subtrace/subtrace / getThreadGroupID

Function getThreadGroupID

cmd/run/engine/engine.go:361–382  ·  view source on GitHub ↗
(pid int)

Source from the content-addressed store, hash-verified

359}
360
361func getThreadGroupID(pid int) (int, error) {
362 path := fmt.Sprintf("/proc/%d/status", pid)
363 b, err := os.ReadFile(path)
364 if err != nil {
365 return 0, fmt.Errorf("read %s: %w", path, err)
366 }
367
368 for _, line := range strings.Split(string(b), "\n") {
369 k, v, ok := strings.Cut(line, ":")
370 if !ok {
371 continue
372 }
373 if strings.TrimSpace(k) == "Tgid" {
374 tgid, err := strconv.Atoi(strings.TrimSpace(v))
375 if err != nil {
376 return 0, fmt.Errorf("parse tgid: %w", err)
377 }
378 return tgid, nil
379 }
380 }
381 return 0, fmt.Errorf("parse tgid: row not found")
382}

Callers 1

ensureProcessLockedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected