sync.c (624B)
1 /* see LICENSE file for copyright and license details */ 2 #ifndef _XOPEN_SOURCE 3 #define _XOPEN_SOURCE 500 4 #endif 5 6 #include <unistd.h> 7 8 #include "arg.h" 9 #include "util.h" 10 11 // ?man sync: flush disk cache 12 // ?man synopsis: 13 // ?man The sync utility invokes sync(2) to flush all unwritten changes to disk. this is usually done 14 // ?man before shutting down, rebooting or halting. 15 // ?man ## SEE ALSO 16 // ?man fsync(2), sync(2) 17 18 static void 19 usage(void) 20 { 21 eprintf("usage: %s\n", argv0); 22 } 23 24 int 25 main(int argc, char *argv[]) 26 { 27 ARGBEGIN 28 { 29 default: 30 usage(); 31 } 32 ARGEND 33 34 if (argc) 35 usage(); 36 sync(); 37 38 return 0; 39 }