Replace umask() with chmod() because it's not thread-safe.