[Bug libstdc++/106296] New: Consider using fsync or fdatasync in filesystem::copy_file

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jul 14 13:32:18 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106296

            Bug ID: 106296
           Summary: Consider using fsync or fdatasync in
                    filesystem::copy_file
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Writing the file to disk might be slow and could be interrupted by a signal. If
we don't flush explicitly, it will happen when closing the file descriptor, but
if that's interrupted by a signal we don't know if the file was closed or not.

Consider using fsync to flush the data explicitly, looping on EINTR, so that
there's nothing more to do when closing the file.


More information about the Gcc-bugs mailing list