Proper pid checking implementation. Fixes #5