Hi Philip,
Unfortunately I think this is a generic problem with having a files
structure shared among clone processes. I've been pondering this since
Ingo posted a report about problems with using CLONE_FILES a few days
ago, and I don't see any way that the files can be shared safely unless
the set of files is totally static (i.e. none are ever closed.)
The root of the problem is that when accessing a file, the fd is checked
to be in a valid range, then a check is made for a file in that slot.
After that, the process uses the file pointer without bumping the use
count. So if any other clone decides to close the file, you've got
trouble (as you noted.)
The only general short-term fix I've thought of would be to just copy
the files structure even if CLONE_FILES is specified.
Regards,
Bill