#include <unistd.h>
void sync(void);
It should be used by programs that examine a file system, such as fsck(1M) , df(1M) , etc. It is mandatory before a re-boot.
The writing, although scheduled, is not necessarily completed before sync() returns. The fsync function completes the writing before it returns.