OSDN Git Service

36ea5892bae1cbcb2b13cae011b63fe9b4af3604
[linuxjm/LDP_man-pages.git] / original / man2 / inotify_init.2
1 .\" Copyright (C) 2005 Robert Love
2 .\" and Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
26 .\" 2006-02-07 mtk, minor changes
27 .\" 2008-10-10 mtk: add description of inotify_init1()
28 .\"
29 .TH INOTIFY_INIT 2 2014-03-28 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 inotify_init, inotify_init1 \- initialize an inotify instance
32 .SH SYNOPSIS
33 .nf
34 .B #include <sys/inotify.h>
35 .sp
36 .B "int inotify_init(void);"
37 .BI "int inotify_init1(int " flags );
38 .fi
39 .SH DESCRIPTION
40 For an overview of the inotify API, see
41 .BR inotify (7).
42
43 .BR inotify_init ()
44 initializes a new inotify instance and returns a file descriptor associated
45 with a new inotify event queue.
46
47 If
48 .I flags
49 is 0, then
50 .BR inotify_init1 ()
51 is the same as
52 .BR inotify_init ().
53 The following values can be bitwise ORed in
54 .IR flags
55 to obtain different behavior:
56 .TP 12
57 .B IN_NONBLOCK
58 Set the
59 .BR O_NONBLOCK
60 file status flag on the new open file description.
61 Using this flag saves extra calls to
62 .BR fcntl (2)
63 to achieve the same result.
64 .TP
65 .B IN_CLOEXEC
66 Set the close-on-exec
67 .RB ( FD_CLOEXEC )
68 flag on the new file descriptor.
69 See the description of the
70 .B O_CLOEXEC
71 flag in
72 .BR open (2)
73 for reasons why this may be useful.
74 .SH RETURN VALUE
75 On success, these system calls return a new file descriptor.
76 On error, \-1 is returned, and
77 .I errno
78 is set to indicate the error.
79 .SH ERRORS
80 .TP
81 .B EINVAL
82 .RB ( inotify_init1 ())
83 An invalid value was specified in
84 .IR flags .
85 .TP
86 .B EMFILE
87 The user limit on the total number of inotify instances has been reached.
88 .TP
89 .B ENFILE
90 The system limit on the total number of file descriptors has been reached.
91 .TP
92 .B ENOMEM
93 Insufficient kernel memory is available.
94 .SH VERSIONS
95 .BR inotify_init ()
96 first appeared in Linux 2.6.13;
97 library support was added to glibc in version 2.4.
98 .BR inotify_init1 ()
99 was added in Linux 2.6.27;
100 library support was added to glibc in version 2.9.
101 .SH CONFORMING TO
102 These system calls are Linux-specific.
103 .SH SEE ALSO
104 .BR inotify_add_watch (2),
105 .BR inotify_rm_watch (2),
106 .BR inotify (7)
107 .SH COLOPHON
108 This page is part of release 3.67 of the Linux
109 .I man-pages
110 project.
111 A description of the project,
112 information about reporting bugs,
113 and the latest version of this page,
114 can be found at
115 \%http://www.kernel.org/doc/man\-pages/.