A container registry that uses the AT Protocol for manifest storage and S3 for blob storage.
atcr.io
docker
container
atproto
go
1package main
2
3import (
4 "fmt"
5 "os"
6 "strconv"
7 "strings"
8)
9
10// getProcessArgs reads /proc/<pid>/cmdline to get process arguments.
11func getProcessArgs(pid int) ([]string, error) {
12 data, err := os.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid))
13 if err != nil {
14 return nil, fmt.Errorf("reading /proc/%d/cmdline: %w", pid, err)
15 }
16
17 s := strings.TrimRight(string(data), "\x00")
18 if s == "" {
19 return nil, fmt.Errorf("empty cmdline for pid %d", pid)
20 }
21
22 return strings.Split(s, "\x00"), nil
23}
24
25// getParentPID reads /proc/<pid>/status to find the parent PID.
26func getParentPID(pid int) (int, error) {
27 data, err := os.ReadFile(fmt.Sprintf("/proc/%d/status", pid))
28 if err != nil {
29 return 0, err
30 }
31
32 for _, line := range strings.Split(string(data), "\n") {
33 if strings.HasPrefix(line, "PPid:") {
34 fields := strings.Fields(line)
35 if len(fields) >= 2 {
36 return strconv.Atoi(fields[1])
37 }
38 }
39 }
40
41 return 0, fmt.Errorf("PPid not found in /proc/%d/status", pid)
42}