[Toybox] [PATCH] Offer flag to only list open FDs.
Rob Landley
rob at landley.net
Wed Oct 26 18:11:51 PDT 2016
On 10/26/2016 11:50 AM, Jeff Sharkey wrote:
> Doh, I forgot that toybox tries as much as possible to mirror upstream
> behavior, so ignore my attempt to redefine "-f".
It's not absolute: I'll deviate from posix, from lsb, from what ubuntu's
doing, etc. But I like to have a reason for it, and to document that I'm
doing it.
For example my "top" implementation is quite bespoke, but "cursor left
and right to change what fields you're sorting by", and then making ps's
arguments apply to top as well (so top -O does what you think), and
making the display values all be acceptable as -o inputs and vice
versa... seemed like the obvious way to do it. (I'd like to write up a
"why i did stuff in top that way" document but dunno where to stick it.
The --help text is intentionally terse, but "-O adds fields to a default
set but it's nto THE default set, it chops out NI VIRT RES SHR S to make
room"... well hopefully people will pick it up from context?)
> Looking at the lsof manpage, there isn't really a direct flag that does
> what I'm looking for. :( The closest thing would be something like:
>
> $ lsof -a -p [pid] -d 0-1024
I admit that part of the reason lsof is still in pending is I'm not an
lsof expert and haven't had time to become one. The ubuntu version has 8
gazillion options, no clear explanation of what they do or how they
interrelate (unless I make time to sit down and study a 2714 lines man
page), and its _default_ behavior is:
$ time lsof | wc
320043 3158672 42397642
real 0m31.972s
user 0m16.456s
sys 0m16.080s
This is a HUGELY USEFUL command and I want to make it waaaaaay less
impenetrable. Haven't figured out how yet. Ideally lsof, like ps, would
show by default a more localized set of processes. But I guess that's
what lsof ~ is for... no, that just shows stuff using the directory
itself, is there a -r option for things _under_ that directory? If there
is I can't find it...
Ok, what does this set of flags do:
-a: must match all criteria ("and" mode)
-p: select process id(s).
Can you have -p without an argument? the bracketing above implies -p is
required but its argument can be skipped, my parsing itsn't currently
set up to do that, and I dunno what -p by itself would mean...
-d: Show only the first 1025 file descriptors.
Ok. Seems reasonable? (Does "lsof -d cwd" work? Ah, yes it does. Very
nice. Ours should do that.)
> Which isn't pretty at all. I think I can get the bare-bones info I need
> with `ls -lf /proc/[pid]/fd/`, so I'll go that direction for now. Sorry
> for the noise.
Nothing to apologize for, you came to me with a feature request and I'm
trying to figure out the right way accomplish it.
You asked for a simple change, and tweaking UI isn't a big deal. If we
couldn't find a flag value the old lsof isn't already using we could
always add a --bare-longopt with no corresponding short option.
(--fd-only" is kinda awkward, but doesn't conflict with anything.)
However it sounds like -d 0-99999 is what you really want here. The -ap
12345 thing and/or -au $UID and similar combine with that to filter your
selection the same way "find -type f" does. So what you're saying is I
need to fill in more of the lsof filter options. :)
But I can't personally bang on it too much until after I get through
this gps stuff for $DAYJOB. (I'm half a week into another trip to Tokyo:
my code's finding bit boundaries in the raw correlator output,
downsampling, recognizing subframes, checking/stripping parity data, and
calling rtklib to convert the subframes to ephemeris data structures,
which have the correct timestamps for when they were collected! Woo!
Next we need to synthesize observation structures! Plus hook up the real
comparator hardware instead of feeding it stored inputs from last year
laboriously correlated by scilab, but that's the guys on the second
floor working on that end; the board needs to DMA the register data into
a ring buffer to make that part tractable on a 62.5mhz processor, and
that's new VHDL. That was also "wednesday". Today I am missing
http://elinux.org/Japan_Technical_Jamboree_58-1 because of customer
deadlines, and should get back to it...)
> j
Rob
More information about the Toybox
mailing list