MCPcopy
hub / github.com/docker/compose / inotifyNodes

Function inotifyNodes

pkg/watch/watcher_naive_test.go:122–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120}
121
122func inotifyNodes() (int, error) {
123 pid := os.Getpid()
124
125 output, err := exec.Command("/bin/sh", "-c", fmt.Sprintf(
126 "find /proc/%d/fd -lname anon_inode:inotify -printf '%%hinfo/%%f\n' | xargs cat | grep -c '^inotify'", pid)).Output()
127 if err != nil {
128 return 0, fmt.Errorf("error running command to determine number of watched files: %w\n %s", err, output)
129 }
130
131 n, err := strconv.Atoi(strings.TrimSpace(string(output)))
132 if err != nil {
133 return 0, fmt.Errorf("couldn't parse number of watched files: %w", err)
134 }
135 return n, nil
136}
137
138func TestDontRecurseWhenWatchingParentsOfNonExistentFiles(t *testing.T) {
139 if runtime.GOOS != "linux" {

Calls 1

CommandMethod · 0.80

Tested by

no test coverage detected