bpo-33630: Fix race condition in TestPosixSpawn.test_open
by pablogsal · Pull Request #7663 · python/cpython (original) (raw)
I have simplified this bugfix:
As far as I understand this won't finish until the inode is created and the data is written to disk:
import sys, os
sys.stdout.write("hello")
sys.stdout.flush()
os.fsync(sys.stdout.fileno())
and on the parent waitpid
blocks until the child finished with 0 (otherwise it fails the check):
self.assertEqual(os.waitpid(pid, 0), (pid, 0))
Unless I am missing something there is no race condition. When waitpid
exists successfully, the file has to be there.