OSDN Git Service

71396f6d01950674c3071d3dd504e0516aef4446
[linuxjm/LDP_man-pages.git] / original / man2 / sync.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified Sat Jul 24 12:02:47 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 15 Apr 1995 by Michael Chastain <mec@shell.portal.com>:
28 .\"   Added reference to `bdflush(2)'.
29 .\" Modified 960414 by Andries Brouwer <aeb@cwi.nl>:
30 .\"   Added the fact that since 1.3.20 sync actually waits.
31 .\" Modified Tue Oct 22 22:27:07 1996 by Eric S. Raymond <esr@thyrsus.com>
32 .\" Modified 2001-10-10 by aeb, following Michael Kerrisk.
33 .\"
34 .TH SYNC 2 2010-09-20 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 sync \- commit buffer cache to disk
37 .SH SYNOPSIS
38 .B #include <unistd.h>
39 .sp
40 .B void sync(void);
41 .sp
42 .in -4n
43 Feature Test Macro Requirements for glibc (see
44 .BR feature_test_macros (7)):
45 .in
46 .sp
47 .BR sync ():
48 .ad l
49 .RS 4
50 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
51 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
52 .RE
53 .ad
54 .SH DESCRIPTION
55 .BR sync ()
56 first commits inodes to buffers, and then buffers to disk.
57 .SH ERRORS
58 This function is always successful.
59 .SH "CONFORMING TO"
60 SVr4, 4.3BSD, POSIX.1-2001.
61 .SH NOTES
62 Since glibc 2.2.2 the Linux prototype is as listed above,
63 following the various standards.
64 In libc4, libc5, and glibc up to 2.2.1
65 it was "int sync(void)", and
66 .BR sync ()
67 always returned 0.
68 .SH BUGS
69 According to the standard specification (e.g., POSIX.1-2001),
70 .BR sync ()
71 schedules the writes, but may return before the actual
72 writing is done.
73 However, since version 1.3.20 Linux does actually wait.
74 (This still does not guarantee data integrity: modern disks have
75 large caches.)
76 .SH "SEE ALSO"
77 .BR bdflush (2),
78 .BR fdatasync (2),
79 .BR fsync (2),
80 .BR sync (8),
81 .BR update (8)