bugfix: move mlock to after detach() so it works for child, not parent