sync calls
sync(2), which causes all information in memory that updates
file systems to be scheduled for writing out to all file systems. The writing, although scheduled, is not necessarily complete upon
return from
sync.
Since sync(2) has no failure indication, sync only fails for
option/operand syntax errors, or when sync(2) does not return, in which case sync
also does not return.
At minimum sync should be called before halting the system. Most systems provide graceful shutdown procedures that include
sync -- use them if possible.