https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119136
--- Comment #11 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to Jerry DeLisle from comment #10) > I looking around in libgfortran/io I found a file called lock.c. > > At the top of this file is a comment: > > /* Thread/recursion locking ... > > The content of the file is very short and it contains no obvious locking > mechanism though I can see how we might do this. The file was created in > 2004. Thus, "we" have been aware of this requirement since the creation of > the universe. > > I think this will be a good place to put a check. We do have to be careful > of the asynchronous I/O implemented elsewhere. I will be thinking on this. One option would be to extend find_unit and find_or_create unit (then handed down to get_gfc_unit) with a flag which specifies that, while the unit is locked, an "in exclusive use" flag should checked. If it is set, abort with an error, otherwise set it. This would be set on read and write, for example. It would then also be necessary to clear that flag on st_write_done / st_read_done, for example.
