inotify_init(2)
๐ inotify_init โ it's in the inotify_init(2) era, bestie ๐
okay so this is a page from the System Calls Manual, and we're talking about initializing an inotify instance. Get comfy ๐ซถ
โจ NAME โจ
inotify_init, inotify_init1 โ initialize an inotify instance
No cap, that's literally the whole job. You're building a little inotify baby. ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โ the classic. The OG. We stan.
๐ธ SYNOPSIS ๐ธ
#include <sys/inotify.h>
int inotify_init(void);
int inotify_init1(int flags);
Look at those two. Sisters. One of them takes a flags argument, one of them is a no-argument girlie who keeps it simple. Both iconic. ๐
๐ฆ DESCRIPTION ๐ฆ
Wanna know the whole big picture of the inotify API? Go read inotify(7). That's the vibe overview, this is the specific-girl page.
inotify_init() initializes a new inotify instance and returns a file descriptor associated with a new inotify event queue. That's it, that's the whole plot. You get a fd, the fd has its own event queue, you go watch files with your new bestie. ๐
Now โ if flags is 0, then inotify_init1() is doing literally the exact same thing as inotify_init(). Same girl, different outfit.
But! You can bitwise OR the following values into flags to get different behavior, and this is where it gets juicy:
IN_NONBLOCKโ sets theO_NONBLOCKfile status flag on the open file description (peepopen(2)for that concept) that the new file descriptor refers to. Using this flag saves you extra calls tofcntl(2)to achieve the same result. Likeโฆ why do two steps when one step slays? ๐ฅIN_CLOEXECโ sets the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. If you wanna know why that's useful, go read the description of theO_CLOEXECflag inopen(2). Trust, it's a whole thing. ๐
๐ RETURN VALUE ๐
On success, these system calls return a new file descriptor. Yay! New fd! ๐
On error, -1 is returned, and errno is set to tell you what went wrong. It's giving "the universe is explaining itself to you." ๐ญ
๐ ERRORS ๐
Every one of these is a little heartbreak, so let's go through the whole roster, fr fr:
EINVALโ only frominotify_init1(). An invalid value was specified inflags. Girl. You put something illegal inflags. ๐EMFILEโ the user limit on the total number of inotify instances has been reached. You maxed out your personal inotify allowance. ๐ญEMFILEโ the per-process limit on the number of open file descriptors has been reached. Same error name, different flavor of too-much. Yes, it shows up twice. It really said "I contain multitudes." ๐ENFILEโ the system-wide limit on the total number of open files has been reached. Not just you โ the entire system is booked and busy. ๐ฅENOMEMโ insufficient kernel memory is available. The kernel is tired. No thoughts, head empty, out of memory. ๐ง
๐ STANDARDS ๐
Linux.
That's the standard. That's the list. Periodt.
๐ HISTORY ๐
Baby photos of the two functions:
inotify_init()โ Linux 2.6.13, glibc 2.4. An elder. Respect her. ๐ซถinotify_init1()โ Linux 2.6.27, glibc 2.9. The younger sister who showed up with aflagsargument and changed the game. โญ
โญ SEE ALSO โญ
Go be nosy, bestie:
iykyk โ that's the whole friend group right there. ๐ธ
okay and finally, the little sign-off: this was pulled from Linux man-pages 6.20, dated 2026-02-08, and the original page was inotify_init(2) โ so if you ever need to cite your sources for the group chat, now you have them. mwah ๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- Copyright 2005, Robert Love <rlove@rlove.org>
- Copyright 2008, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms