backported piddir patch from cfengine master branch