fanotify_mark.2: ERRORS: add missing EBADF error for invalid 'dirfd'
[man-pages.git] / man2 / inotify_init.2
blobb166fdd4356a71539c22a000d039d6632ce94aa4
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 2020-04-11 "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 .PP
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 .PP
43 .BR inotify_init ()
44 initializes a new inotify instance and returns a file descriptor associated
45 with a new inotify event queue.
46 .PP
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
57 .B IN_NONBLOCK
58 Set the
59 .BR O_NONBLOCK
60 file status flag on the open file description (see
61 .BR open (2))
62 referred to by the new file descriptor.
63 Using this flag saves extra calls to
64 .BR fcntl (2)
65 to achieve the same result.
66 .TP
67 .B IN_CLOEXEC
68 Set the close-on-exec
69 .RB ( FD_CLOEXEC )
70 flag on the new file descriptor.
71 See the description of the
72 .B O_CLOEXEC
73 flag in
74 .BR open (2)
75 for reasons why this may be useful.
76 .SH RETURN VALUE
77 On success, these system calls return a new file descriptor.
78 On error, \-1 is returned, and
79 .I errno
80 is set to indicate the error.
81 .SH ERRORS
82 .TP
83 .B EINVAL
84 .RB ( inotify_init1 ())
85 An invalid value was specified in
86 .IR flags .
87 .TP
88 .B EMFILE
89 The user limit on the total number of inotify instances has been reached.
90 .TP
91 .B EMFILE
92 The per-process limit on the number of open file descriptors has been reached.
93 .TP
94 .B ENFILE
95 The system-wide limit on the total number of open files has been reached.
96 .TP
97 .B ENOMEM
98 Insufficient kernel memory is available.
99 .SH VERSIONS
100 .BR inotify_init ()
101 first appeared in Linux 2.6.13;
102 library support was added to glibc in version 2.4.
103 .BR inotify_init1 ()
104 was added in Linux 2.6.27;
105 library support was added to glibc in version 2.9.
106 .SH CONFORMING TO
107 These system calls are Linux-specific.
108 .SH SEE ALSO
109 .BR inotify_add_watch (2),
110 .BR inotify_rm_watch (2),
111 .BR inotify (7)