Create pid directory at the right moment