Enter cgroups as part of NsEnter

Refactored this code.