Fixing more build problems in MinGW

- Windows does not have wait.h

- More usages of S_IRGRP && S_IROTH