File tree 1 file changed +25
-0
lines changed
cmd/containerd-shim-runc-v2/process
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,10 @@ package process
20
20
21
21
import (
22
22
"context"
23
+ "fmt"
23
24
"net/url"
24
25
"os"
26
+ "strings"
25
27
"testing"
26
28
27
29
"github.com/containerd/containerd/v2/pkg/namespaces"
@@ -68,5 +70,28 @@ func TestNewBinaryIOCleanup(t *testing.T) {
68
70
func descriptorCount (t * testing.T ) int {
69
71
t .Helper ()
70
72
files , _ := os .ReadDir ("/proc/self/fd" )
73
+
74
+ // Go 1.23 introduced a new internal file descriptor type "pidfd"
75
+ // that we don't want to count towards the total file descriptors in
76
+ // use by the process. This retains the behavior of previous Go
77
+ // versions.
78
+ // See https://go.dev/issues/62654.
79
+ //
80
+ // Once the proposal to check for internal file descriptors is
81
+ // accepted, we can use that instead to detect internal fds in use
82
+ // by the Go runtime.
83
+ // See https://go.dev/issues/67639.
84
+ for i , file := range files {
85
+ sym , err := os .Readlink (fmt .Sprintf ("/proc/self/fd/%s" , file .Name ()))
86
+ if err != nil {
87
+ // ignore fds that cannot be followed.
88
+ continue
89
+ }
90
+
91
+ if strings .HasPrefix (sym , "pidfd:" ) {
92
+ files = append (files [:i ], files [i + 1 :]... )
93
+ }
94
+ }
95
+
71
96
return len (files )
72
97
}
You can’t perform that action at this time.
0 commit comments