Skip to content

Replace inotifywait with polling in cgroup cleanup#37

Open
assisted-by-ai wants to merge 2 commits into
Kicksecure:masterfrom
assisted-by-ai:claude/fix-inotifywait-enospc-ve1mb
Open

Replace inotifywait with polling in cgroup cleanup#37
assisted-by-ai wants to merge 2 commits into
Kicksecure:masterfrom
assisted-by-ai:claude/fix-inotifywait-enospc-ve1mb

Conversation

@assisted-by-ai

Copy link
Copy Markdown
Contributor

Summary

Refactored the cgroup cleanup logic to use polling instead of inotifywait, eliminating dependency on the kernel's limited inotify watch pool and preventing ENOSPC errors on watch-constrained systems.

Key Changes

  • Replaced inotifywait-based event monitoring with a simple polling loop that checks cgroup.events up to 50 times
  • Removed file descriptor management and subshell complexity associated with inotifywait
  • Simplified variable declarations by removing inotifywait_subshell_pid and inotifywait_fd, replacing with cgroup_drained and poll_count
  • Added timeout detection with warning log when cgroup fails to drain within the polling limit
  • Moved cgroup.kill write before the polling loop (more logical flow)
  • Maintained the same 0.1 second sleep interval between polls for consistent behavior

Implementation Details

  • The polling approach is viable because cgroup.kill sends SIGKILL, so draining is near-instant
  • Maximum wait time is ~5 seconds (50 polls × 0.1 second sleep)
  • Cleaner error handling with explicit cgroup_drained flag instead of relying on subshell exit status
  • Reduced kernel resource consumption by eliminating inotify watch usage

https://claude.ai/code/session_01V4XkxCqroKpfDZE2Jknmdx

@ArrayBolt3

Copy link
Copy Markdown
Contributor

Accepted in ArrayBolt3@36e9838.

@assisted-by-ai assisted-by-ai force-pushed the claude/fix-inotifywait-enospc-ve1mb branch from dd18a8d to 0263512 Compare April 27, 2026 18:29
@ArrayBolt3

Copy link
Copy Markdown
Contributor

Accepted the followup commit in ArrayBolt3@ac45d4f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants