inotify_rm_watch(2)

โœจ inotify_rm_watch(2) โœจ

okay bestie so this is a page from the System Calls Manual ๐Ÿ’– it's literally called inotify_rm_watch and it lives in section 2, and it's about removing an existing watch from an inotify instance ๐ŸŽ€ yes we're breaking up with a watch. it's not you it's the file descriptor. ๐Ÿ’…


๐Ÿซถ NAME ๐Ÿซถ

inotify_rm_watch โ€” remove an existing watch from an inotify instance

no cap, that's the whole thing. you had a watch, now you don't. character development โœจ


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc)

yep bestie you gotta link the libc, -lc, standard behavior, iconic ๐Ÿ’œ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <sys/inotify.h>

int inotify_rm_watch(int fd, int wd);

two ints in, one int out. it's giving minimalism. it's giving elegance. ๐ŸŽ€


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so inotify_rm_watch() removes the watch associated with the watch descriptor wd from the inotify instance associated with the file descriptor fd.

that's it. that's the function. you hand it the fd (the inotify instance, the whole vibe) and the wd (the specific watch descriptor, the one little watch you're sick of), and it un-watches it. bye bestie ๐Ÿ‘‹

and here's the fun part โ€” the plot twist, the lore drop โ€” removing a watch causes an IN_IGNORED event to be generated for this watch descriptor. ๐Ÿ‘€ like, the watch doesn't just ghost you silently, it files an official event about it. (go read inotify(7) for the details, iykyk) ๐Ÿ“–

fr fr, expect that IN_IGNORED event in your event stream. it's not a bug it's a feature, it's the watch going "aight imma head out" ๐Ÿ’€

โญ RETURN VALUE โญ

  • On success, inotify_rm_watch() returns zero โœจ slay.
  • On error, -1 is returned and errno is set to indicate the error ๐Ÿ˜ญ

so fr fr, check your return value. zero means we ate. -1 means we gotta go read errno and have a little cry. ๐Ÿซถ


๐Ÿ’€ ERRORS ๐Ÿ’€

  • EBADF โ€” fd is not a valid file descriptor. that fd is not real, not valid, not welcome here. ๐Ÿ’…
  • EINVAL โ€” the watch descriptor wd is not valid; or fd is not an inotify file descriptor. like, you gave me a wd that doesn't exist, OR you gave me an fd that isn't even an inotify file descriptor. either way bestie, no. ๐Ÿšซ

๐Ÿ‘‘ STANDARDS ๐Ÿ‘‘

Linux. that's it. that's the standard. ๐Ÿ‡ฑ๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ‡บ๐Ÿ‡ฝ


๐ŸŽ€ HISTORY ๐ŸŽ€

Linux 2.6.13. an elder. a legend. it's been here since forever and it's still serving. โญ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • inotify_add_watch(2) โ€” the other half of the duo, the one that ADDS the watch. they're literally a matched set. ๐Ÿฆ‹
  • inotify_init(2) โ€” where the inotify instance comes from in the first place. the origin story. ๐ŸŒธ
  • inotify(7) โ€” the full lore, the IN_IGNORED deep dive, everything you ever wanted to know. read it, bestie. ๐Ÿ“–

okay that's the whole page, no cap ๐Ÿ’– this one's from Linux man-pages 6.20, dated 2026-02-08 โ€” so like, shoutout to the man-pages girlies for keeping the docs fresh โœจ go remove some watches responsibly, 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms