Revert "removed usage of getmypid() which is not always available"

This reverts commit 84ff290871c3436c3703ce15ec5e344da0b59472.