stat() before open() to avoid failure on unix sockets