在UNIX环境高级环境编程中,大家应该都看到过:

sync函数

     sync函数只是将所有修改过的块缓冲区排入写队列,然后就返回,它并不等待实际写磁盘操作结束。
     通常称为update的系统守护进程会周期性地(一般每隔30秒)调用sync函数。这就保证了定期冲洗内核的块缓冲区。命令sync(1)也调用sync函数

 上面这段话在Linux当中是不成立的。可以参考如下这段话:

Since glibc 2.2.2, the Linux prototype for sync() is as listed
       above, following the various standards.  In glibc 2.2.1 and
       earlier, it was "int sync(void)", and sync() always returned 0.

       According to the standard specification (e.g., POSIX.1-2001),
       sync() schedules the writes, but may return before the actual
       writing is done.  However Linux waits for I/O completions, and
       thus sync() or syncfs() provide the same guarantees as fsync()
       called on every file in the system or filesystem respectively.

       In mainline kernel versions prior to 5.8, syncfs() will fail only
       when passed a bad file descriptor (EBADF).  Since Linux 5.8,
       syncfs() will also report an error if one or more inodes failed
       to be written back since the last syncfs() call.

 sync(2) - Linux manual page

https://man7.org/linux/man-pages/man2/sync.2.html

所以想使用这个函数刷写缓冲区的内容到磁盘的可以放心使用,sync调用返回后,代表已经完成了写磁盘操作。