Help language development. Donate to The Perl Foundation

Linux::Fuser cpan:JSTOWE last updated on 2021-03-09

bin/raku-fuser
#!/usr/bin/env raku

use v6;

use Linux::Fuser;

multi sub MAIN(Bool :$u = False) {
    my $progname = $*PROGRAM-NAME.IO.basename;
    note "$progname: USAGE: $progname [-u] <filename> [<filename> ..]";
    exit(1);
}

multi sub MAIN(Bool :$u = False, *@files) {
    my $fuser = Linux::Fuser.new();
    for @files  -> $file {
        for $fuser.fuser($file) -> $proc {
            print $proc.pid, $u ?? '(' ~ $proc.user ~ ')' !! '', "\t";
        }
        say '';
    }
}

# vim: expandtab shiftwidth=4 ft=raku