9fans archive / 1998 / 02 / 48 / prev next From: G. David Butler gdb@dbS... Subject: [9fans] create(2)/open(2) race for file creation Date: Wed, 25 Feb 1998 17:42:34 -0600 I'm sure many of you wish this topic would go away, but... As you can guess I have made the change I have been advocating in this thread and have found an interesting race that affects everybody. In /sys/src/cmd/rc/plan9.c in the function Execute the statement Updenv(); Is in a race with the same call in /sys/src/cmd/rc/simple.c in the function Xsimple(). During the fork and subsequent exec, both the parent and child are writing the environment with sometimes spectacular results. With the new create(2), I saw periodic rc: can't open #e/blah since Create() in /sys/src/cmd/rc/plan9.c now has open(OWRITE|OTRUNC) and only if that fails create(OWRITE). If I add the additional open(OWRITE|OTRUNC) call to emulate the old create(2) call, the race stays hidden. I took out the Updenv() in Execute to follow /sys/src/cmd/rc/unix.c and because it makes sense. Also, if anybody is interested, the OTRUNC handling in /sys/src/9/port/devenv.c needs to include things other than OWRITE. David Butler gdb@dbS...