[Toybox] ps -t is cheating.

lamiaworks lamiaworks at skymesh.com.au
Mon Oct 19 22:43:06 PDT 2015


> Message: 1
> Date: Mon, 19 Oct 2015 00:09:17 -0500
> From: Rob Landley <rob at landley.net>
> To: toybox at lists.landley.net
> Subject: [Toybox] ps -t is cheating.
> Message-ID: <56247AFD.5050806 at landley.net>
> Content-Type: text/plain; charset=utf-8
>
> So posix says this:
>
> -t  termlist
>    Write information for processes associated with terminals given in
>    termlist. The application shall ensure that the termlist is a single
>    argument in the form of a <blank> or <comma>-separated list. Terminal
>    identifiers shall be given in an implementation-defined format. [XSI]
>    [Option Start]  On XSI-conformant systems, they shall be given in one
>    of two forms: the device's filename (for example, tty04) or, if the
>    device's filename starts with tty, just the identifier following the
>    characters tty (for example, "04" ). [Option End]
>
> And once again posix is somewhere back before the 1980's because
> pseudo-terminals do not start with "/dev/tty". In the case of linux,
> they've been /dev/pts/12 since, apparently, 1998.
>
> 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.

You just brought an old nightmare back to the surface...

Try -t 05, if setup 'properly' you should get tty05 and that nowadays 
should be equating to tty5's inode / character settings.

My first Mainframes (1970's) had tty0 to ttyf for systems consoles I/O 
ONLY, and tty00 to ttyff for user terminals. The problem was of course 
cost for the extra user i/o cards so any tty above tty3 were often 
assigned to users terminals and the relevant code 'fudged' to remove the 
console level access and assign user inodes, which in turn fudged other 
bits of code....et al...

>
> 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...
>



 1445319786.0


More information about the Toybox mailing list