@@ -27,7 +27,6 @@ import (
2727 "path/filepath"
2828 "strconv"
2929 "strings"
30- "syscall"
3130 "time"
3231
3332 "github.com/containerd/cgroups/v3/cgroup2/stats"
@@ -707,19 +706,19 @@ func (c *Manager) isCgroupEmpty() bool {
707706// MemoryEventFD returns inotify file descriptor and 'memory.events' inotify watch descriptor
708707func (c * Manager ) MemoryEventFD () (int , uint32 , error ) {
709708 fpath := filepath .Join (c .path , "memory.events" )
710- fd , err := syscall .InotifyInit ()
709+ fd , err := unix .InotifyInit ()
711710 if err != nil {
712711 return 0 , 0 , errors .New ("failed to create inotify fd" )
713712 }
714- wd , err := syscall .InotifyAddWatch (fd , fpath , unix .IN_MODIFY )
713+ wd , err := unix .InotifyAddWatch (fd , fpath , unix .IN_MODIFY )
715714 if err != nil {
716- syscall .Close (fd )
715+ unix .Close (fd )
717716 return 0 , 0 , fmt .Errorf ("failed to add inotify watch for %q: %w" , fpath , err )
718717 }
719718 // monitor to detect process exit/cgroup deletion
720719 evpath := filepath .Join (c .path , "cgroup.events" )
721- if _ , err = syscall .InotifyAddWatch (fd , evpath , unix .IN_MODIFY ); err != nil {
722- syscall .Close (fd )
720+ if _ , err = unix .InotifyAddWatch (fd , evpath , unix .IN_MODIFY ); err != nil {
721+ unix .Close (fd )
723722 return 0 , 0 , fmt .Errorf ("failed to add inotify watch for %q: %w" , evpath , err )
724723 }
725724
@@ -777,16 +776,16 @@ func (c *Manager) waitForEvents(ec chan<- Event, errCh chan<- error) {
777776 errCh <- err
778777 return
779778 }
780- defer syscall .Close (fd )
779+ defer unix .Close (fd )
781780
782781 for {
783- buffer := make ([]byte , syscall .SizeofInotifyEvent * 10 )
784- bytesRead , err := syscall .Read (fd , buffer )
782+ buffer := make ([]byte , unix .SizeofInotifyEvent * 10 )
783+ bytesRead , err := unix .Read (fd , buffer )
785784 if err != nil {
786785 errCh <- err
787786 return
788787 }
789- if bytesRead >= syscall .SizeofInotifyEvent {
788+ if bytesRead >= unix .SizeofInotifyEvent {
790789 out := make (map [string ]interface {})
791790 if err := readKVStatsFile (c .path , "memory.events" , out ); err != nil {
792791 // When cgroup is deleted read may return -ENODEV instead of -ENOENT from open.
0 commit comments