MCPcopy
hub / github.com/opencontainers/runc / ProcThreadSelfOpen

Function ProcThreadSelfOpen

internal/pathrs/procfs_pathrslite.go:74–101  ·  view source on GitHub ↗

ProcThreadSelfOpen is a wrapper around [procfs.Handle.OpenThreadSelf] and [pathrs.Reopen], to let you one-shot open a procfs file with the given flags. The returned [procfs.ProcThreadSelfCloser] needs the same handling as when using pathrs-lite.

(subpath string, flags int)

Source from the content-addressed store, hash-verified

72// flags. The returned [procfs.ProcThreadSelfCloser] needs the same handling as
73// when using pathrs-lite.
74func ProcThreadSelfOpen(subpath string, flags int) (_ *os.File, _ procfs.ProcThreadSelfCloser, Err error) {
75 proc, err := retryEAGAIN(procfs.OpenProcRoot)
76 if err != nil {
77 return nil, nil, err
78 }
79 defer proc.Close()
80
81 handle, closer, err := retryEAGAIN2(func() (*os.File, procfs.ProcThreadSelfCloser, error) {
82 return proc.OpenThreadSelf(subpath)
83 })
84 if err != nil {
85 return nil, nil, err
86 }
87 if closer != nil {
88 defer func() {
89 if Err != nil {
90 closer()
91 }
92 }()
93 }
94 defer handle.Close()
95
96 f, err := Reopen(handle, flags)
97 if err != nil {
98 return nil, nil, fmt.Errorf("reopen %s: %w", handle.Name(), err)
99 }
100 return f, closer, nil
101}
102
103// Reopen is a wrapper around pathrs.Reopen.
104func Reopen(file *os.File, flags int) (*os.File, error) {

Callers 6

runMethod · 0.92
fdListFunction · 0.92
testFdLeaksFunction · 0.92
fdRangeFromFunction · 0.92
setProcAttrFunction · 0.92
FchmodFileFunction · 0.92

Calls 4

retryEAGAINFunction · 0.85
retryEAGAIN2Function · 0.85
ReopenFunction · 0.85
CloseMethod · 0.45

Tested by 2

fdListFunction · 0.74
testFdLeaksFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…