One possiblity is open in exclusive mode. The problem is that O_EXCL is only part of open(2), not fopen(3). And we have to use fopen() because we need the "b" mode for binary output on platforms that require it. So I don't think that will work, either.