Sys::Gamin(3pm)
β¨ NAME β¨
ok so Sys::Gamin is a Perl interface to Gamin β which is a File Access Monitor implementation. that's the whole vibe. π
(also hi bestie, this is a <pink>3pm</pink> page, i.e. user-contributed Perl documentation, so you know it's the good stuff π«Ά)
π¦ SYNOPSIS π¦
ok so first, the classic blocking setup:
use Sys::Gamin;
my $fm=new Sys::Gamin;
$fm->monitor('/foo');
$fm->monitor('/foo/bar.txt');
while (1) {
my $event=$fm->next_event; # Blocks
print "Pathname: ", $event->filename,
" Event: ", $event->type, "\n";
}
and then asynchronous mode, for when you're too busy to block π :
while ($fm->pending) {
my $event=$fm->next_event; # Immediate
...
}
# Do something else
πΈ DESCRIPTION πΈ
so basically this module gives you a somewhat higher-level and friendlier interface to the Gamin File Access Monitor API. cute, right? it lets you monitor both local and remote (NFS-mounted) files and directories for common filesystem events. to do that you gotta register "monitors" on specified pathnames and then sit there and wait for events about them. iconic behavior honestly.
now here's a detail that matters: since FAM only deals with absolute pathnames, all paths get canonicalized internally and the monitors are held on those canonical paths. BUT β whenever a path is returned from this module (via which, or monitored with no arguments), you get the originally specified path back, for convenience. thoughtful king π
π MAIN METHODS π
new [ appname ]
creates a new FAM connection. you can hand it an application name if you want. π«
pending
returns true if there's an event waiting. returns immediately β no waiting around, no drama. β¨
next_event
returns the next event in the queue, as an event object. it blocks if necessary until one shows up. it will simply sit there. patiently. π
monitor path [ unique [ type [ depth mask ] ] ]
monitors the specified file or directory. heads up bestie: expect a slew of events immediately (exist and end_exist) which may not interest you at all. it's giving "notifications you didn't ask for". π
uniqueβ if specified and true, it'll throw a warning if the monitored path isn't unique among the ones you're already monitoring. helpful for debugging, but normally this is harmless. no biggie.typeβ may befile,dirorcoll. it defaults tofileordirdepending on what actually exists in the filesystem. if you specifycoll(collection), you pass additionaldepthandmaskarguments β if you ever figure out what that does (SGI does not say). π
cancel path
stops monitoring this path. bye bestie π
monitored [ path ]
lists all currently monitored paths, or checks whether a specific one is being monitored. does not check if a monitor is suspended, so don't get it twisted. π
suspended path
true if the specified monitor is suspended. that's it, that's the method.
suspend [ path ]
suspends monitoring of a path β or all paths if you don't specify one.
resume [ path ]
resumes monitoring of a path β or all paths if you don't specify one. we're so back π«Ά
which event
gives you the pathname for the monitor generating this event. often this will be the same as $event->filename, but it differs in some cases β for example in create events, where filename gives you the basename of the new file, and you must call the which method to figure out the directory of creation, if more than one directory is being monitored. so like, don't skip it. iykyk. π
π EVENT METHODS π
hostname
host of the event. does not seem to work, actually. π
filename
path of the event, according to FAM.
type
type of the event. it's one of these strings, periodt:
changedeletestart_execstop_execcreatemoveackexistend_exist
π BUGS π
most of these can be observed with monitor. not me exposing the module's whole business π
Hostnames
Do not seem to be supplied at all. at all. zero. nada. π
Timing
is somewhat erratic. for example, creating a file that had been monitored and deleted will signal a create event on it, after about a second pause. she's on her own schedule bestie.
Execute Events
are not sent, as far as the author can determine. so like. don't count on them. π
β SEE ALSO β
for the raw SGI interface (which is, and i quote, rather poorly documented), go check out fam(3x).
π«Ά AUTHORS π«Ά
- J. Glick
jglick@sig.bsh.comβ originalSGI::FAMcode, which this module is based on. the blueprint, the blueprint. π - Carlos Garnacho
carlosg@gnome.orgβ slay.
π REVISION π
lib/SGI/FAM.pm last modified Thu, 04 Mar 2005 22:05:42 -0100 release 0.1.
original SGI::FAM module: Copyright (c) 1997 Strategic Interactive Group. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. legal queen. π
ok that's the whole page bestie!! perl v5.34.0, dated 2022-02-06 β and that's the Sys::Gamin(3pm) footer, mwah π go monitor something, love u, bye πβ¨
π¦ where this page comes from
- ubuntu jammy: libsys-gamin-perl 0.1-2build8 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms