Skip to content

Commit 11aafa9

Browse files
committed
Warn about using -p/-P with -f inotify
1 parent 25605bb commit 11aafa9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ static void help (const char *argv0) {
245245
" -J output in JSON stream format\n"
246246
" -L list all filemonitor backends\n"
247247
" -n do not use colors\n"
248-
" -p [pid] only show events from this pid\n"
249-
" -P [proc] events only from process name\n"
248+
" -p [pid] only show events from this pid (Linux: requires -B fanotify)\n"
249+
" -P [proc] events only from process name (Linux: requires -B fanotify)\n"
250250
" -t show timestamps in default logs\n"
251251
" -v show version\n"
252252
" [path] only get events from this path\n"
@@ -350,6 +350,14 @@ int main (int argc, char **argv) {
350350
eprintf ("-c requires -p\n");
351351
return 1;
352352
}
353+
#if __linux__
354+
if ((fm.pid || fm.proc) && fm.backend.name && !strcmp (fm.backend.name, "inotify")) {
355+
eprintf ("Error: the inotify backend cannot filter by -p/-P because the Linux\n"
356+
" inotify API does not report the originating process. Use\n"
357+
" '-B fanotify' (requires root and Linux 2.6.37+) or drop the filter.\n");
358+
return 1;
359+
}
360+
#endif
353361
if (fm.json && !fm.jsonStream) {
354362
printf ("[");
355363
}

0 commit comments

Comments
 (0)