Pattern more closely after jpetazzo/nsenter