From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 7 Feb 1998 23:09:45 -0600 From: G. David Butler gdb@dbSystems.com Subject: [9fans] create(2)/open(2) race for file creation Topicbox-Message-UUID: 71d8e2ac-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19980208050945.Hf14ekRK3vc6wUbQ1cWmXKXmTrd9r1Taqa25gce3FGo@z> >From: "Rob Pike" >Am I missing something? If everyone does create(file, OWRITE, 000) >only one process can succeed. Perm==0 means no one can read or >write the file; if you want one writer, many readers, 004 will do. If I want to create the file, write data and close so that it can be read/written again then I can't leave it 000 or 400, I must leave it 600. So, if many processes are doing: if stat() fails { create() write() chmod() close() } Then it is possible for two or more processes to fail the stat but one to create, write, chmod and close before the other others do create. It is a race that can't be avoided, that I can see. >In other words, it's a create/open race, so don't run that race. I would like to avoid it. Your point is valid if the file is created once and never written to again. That is a big restriction.