On 10/19/2015 11:40 PM, Isaac Dunham wrote: > On Mon, Oct 19, 2015 at 12:09:17AM -0500, Rob Landley wrote: >> 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. > > VTs start with /dev/tty, as do all interfaces that are theoretically > serial-based. Note that 'if'. > > /dev/pts is actually the result of another part of POSIX (posix_openpt & co.)
There's a kernel .config option for legacy "unix98" ptys... >> 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 ps -t urandom Yup, it took it. > * filenames relative to /dev/pts Like /dev/pts/../zero? Oddly it doesn't seem to like symlinks. ln -s /dev/urandom 1234 neither "ps -t 1234" or "ps -t ./1234" go through. But if I "cp -a /dev/zero" zero and then "ps -t ./zero"... Ah. 'mv zero zzero" then "ps -t ./zzero" and it won't find it, the problem is it forces relative paths to be vs /dev (but doesn't stop you from .. back out of them, so "ps -t ../$HOME/zzero" finds it. What a mess. > * fallback to "/dev/tty<arg>". > No need to special case numbers. The reference question "What does busybox do?" has the answer "Not implement -t." (The option is in posix but not busybox...) > This is *roughly* what procutils is doing, apart from that 'no need to > special-case numbers' I'd assume. Except "ps -t S0" is /dev/ttyS0... > HTH, > Isaac Eh, I can work it out. It's just annoying. Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net