[Toybox] ps -t is cheating.

Rich Felker dalias at libc.org
Mon Oct 19 21:44:44 PDT 2015


On Mon, Oct 19, 2015 at 09:40:08PM -0700, Isaac Dunham wrote:
> > The ps man page says:
> > 
> >   -t ttylist
> >        Select by tty.  This selects the processes associated with the
> >        terminals given in ttylist.  Terminals (ttys, or screens for
> >        text output) can be specified in several forms: /dev/ttyS1,
> >        ttyS1, S1.  A plain "-" may be used to select processes not
> >        attached to any terminal.
> > 
> > Which is, once again, outright lying, because "-t 41" matches pts/41 but
> > -t 5 does _not_ match tty5. You have to say "-t tty5" to get the getty
> > instance on there.
> > 
> > Meanwhile procutils "ps -t pts/41" works as does "ps -t pts/../tty5"
> > which is just _creepy_ and I'm not doing that bit. And -tty S0 is of
> > course /dev/ttyS0 not /dev/pts/S0.
> > 
> > I pine for a spec that means something,
> > 
> > Rob
> > 
> > P.S.  Once again, the hard part is writing help text so ps --help can
> > explain the expected behavior succinctly. Yeah, I can do that, but how
> > do I explain it in a way that makes it sound intentional: -t ## is a pts
> > (unless maybe there isn't one? Does it fall back to tty5 if there's no
> > pts5? Hard to test right now because I've got /dev/pts/68 but only
> > /dev/tty63). Grrr. STOP TRYING TO BE CLEVER IN WAYS YOU DON'T EXPLAIN TO
> > YOUR USERS IN THE MAN PAGE. Right special case "-t number" to be pts/
> > instead of tty, accept pts/ to _not_ mean implicit tty prefix...
> 
> accept the following:
> * filenames relative to /dev
> * filenames relative to /dev/pts
> * fallback to "/dev/tty<arg>".
> No need to special case numbers.

But in that case numbers are ambiguous -- for a given N, it's likely
that both /dev/pts/N and /dev/ttyN exist. And the rule that takes
precedence in your order is contrary to the POSIX spec, tho perhaps it
matches procps. Note that the nastiest part is that, under your
proposed rules, "N" means ttyN if and only if nobody has /dev/pts/N.
So the meaning changes depending on whether a particular pty is
open...

Rich

 1445316284.0


More information about the Toybox mailing list