Re: [Toybox] ps -T
On 10/19/2017 06:13 PM, enh wrote >> On 09/20/2017 05:08 PM, enh wrote: >>> ps -T doesn't really work if you have any filters. so ps -AT is fine, >>> but ps -p -T only shows the main thread. >> >> Alas, I don't personally use threads much so basically never test this. >> >>> why? because slots[SLOT_pid] is "wrong" in shared_match_process (where >>> by wrong i mean "is the tid"). >>> >>> why? because toybox reads (say) /proc/147047/task/147058/stat and sees >>> >>> 147058 (CompositorTileW) S 31782 6249 6249 0 -1 1077952576 4 0 0 0 0 0 >>> 0 0 20 0 11 0 1211910244 928649216 35602 18446744073709551615 >>> 94558515900416 94558627572512 140720560858928 140506510343072 >>> 140506833892356 0 0 4098 1073827581 1 0 0 -1 31 0 0 0 0 0 >>> 94558627579744 94558633602584 9455861888 140720560866826 >>> 140720560866928 140720560866928 140720560869342 0 >>> >>> and copies 147058 into SLOT_pid because that code no longer knows the real >>> pid. I added -H to iotop, fixed the off-by-one error in screen width truncation, set the screen width to 72, and ran "top -H -O TID,SHR" and cursored over to the SHR column and: PID USER TID [SHR]%CPU %MEM TIME+ THREAD PROCE 1865 landley 1865 84M 98.1 14.8 128:47.94 thunderbird thun+ 1865 landley 1895 84M 1.8 14.8 41:53.81 SoftwareVsyncTh thun+ 1865 landley723 84M 0.0 14.8 0:00.00 StreamT~s #3048 thun+ 1865 landley 30482 84M 0.0 14.8 2:14.82 DOM Worker thun+ 1865 landley 9488 84M 0.0 14.8 7:16.20 DOM Worker thun+ 1865 landley 16082 84M 0.0 14.8 15:33.85 DOM Worker thun+ 1865 landley 15523 84M 0.0 14.8 0:00.49 DOM Worker thun+ 1865 landley 12086 84M 0.0 14.8 17:24.69 DOM Worker thun+ 1865 landley 3838 84M 0.0 14.8 18:14.68 DOM Worker thun+ 1865 landley 2254 84M 0.0 14.8 18:26.28 DOM Worker thun+ 1865 landley 30746 84M 0.0 14.8 18:30.12 DOM Worker thun+ An they all seem to think they're PID 1865, but each knows its TID? $ ls /proc/1865/task/ 10228 1865 1875 1880 1887 1893 1899 1911 1934 30482 5471 12086 1871 1876 1881 1888 1894 1903 1912 19926 30746 6316 14369 1872 1877 1882 1889 1895 1904 1921 22017 32148 9488 15523 1873 1878 1885 1891 1897 1906 1927 2254 3838 9955 16082 1874 1879 1886 1892 1898 1908 1933 2770 5469 Which seems reasonable? It's got PID, it's got TID, what do I need to fix here? (Aside: thunderbird really, really, really doesn't like a local linux-kernel folder with 500k messages in it. Or a pop3 inbox going back to 2013, which is the last time I split it. But I think what it's mad about right now is the BUG() I hit in the vfat code which I had to fsck away to do some work, and thus the vfat maintainer couldn't reproduce it. I've meant to reboot ever since, it happened about 5 times before I fixed it, emergency-zapping a filesystem each time, and the memory menagement on this box has gone all wonky since then. I've been meaning to reboot to replace the keyboard anyway, but 8 desktops full of windows full of tabs takes a while to unwind...) >>> not sure how best to fix this. >> >> Hmmm... Reasonably straightforward to fix, Not necessarily straightfowrward to reproduce. $ ps -AT PID TID 32667 32667 ?00:26:22 chromium-browse 32667 32668 ?00:00:00 TaskSchedulerSe 32667 32669 ?00:00:20 Chrome_ChildIOT 32667 32670 ?00:00:00 GpuMemoryThread They're different? $ ls /proc/32667/task/ 10087 32668 32670 32672 32674 5747 5754 32667 32669 32671 32673 32697 5748 And they're reasonable? >> but my tree has local c >> changes in ps.c. Looks like I'm adding -m to show maximum number of >> lines (somebody asked, it's easy enough.) > > i said "no" to the single internal request we had for that when we > switched from traditional Android top to toybox top. easy, yes, but > not obviously useful. the original Android top only had batch mode, so > it was a bit more useful then. but "first N" isn't an obviously > meaningful heuristic. "field X no lower than Y" would be more > convincing. but that's no longer as easy :-) I can yank it again. If you wanna design a filter syntax I can probably implement something. I've just started poking at bc ala shell $((blah)) math syntax, and I'm likely to make a function or two that lets you substitute in variables (via string substitution) and do math on the result. That said... that's not the syntax we've got in find, or in test. And ps has: -o FIELDs instead of defaults, each with optional :size and =title I could add XXX to that, I suppose? Might take a bit of fiddling to make room. That said, you still couldn't implement -m with a syntax like that. Maximum number of fields to display isn't a -o field. :) >> And -H to iotop (which is >> where I left off; need to come up with a test for this and haven't got >> one. Is chrome threads or processes?
Re: [Toybox] ps -T
And this one was stuck in gmail's spam filter too. (Sorry for the delay, the down arrow on my keyboard came off. I have a new keyboard but swapping it out involves shutting this down and closing 6 desktops full of windows full of tabs. Working on it...) [Notices this email didn't get sent, while stopped at a McDonald's in Oklahoma on the drive back from minneapolis to austin. Right, time to press send...] On 09/20/2017 05:08 PM, enh wrote: > ps -T doesn't really work if you have any filters. so ps -AT is fine, > but ps -p -T only shows the main thread. Alas, I don't personally use threads much so basically never test this. > why? because slots[SLOT_pid] is "wrong" in shared_match_process (where > by wrong i mean "is the tid"). > > why? because toybox reads (say) /proc/147047/task/147058/stat and sees > > 147058 (CompositorTileW) S 31782 6249 6249 0 -1 1077952576 4 0 0 0 0 0 > 0 0 20 0 11 0 1211910244 928649216 35602 18446744073709551615 > 94558515900416 94558627572512 140720560858928 140506510343072 > 140506833892356 0 0 4098 1073827581 1 0 0 -1 31 0 0 0 0 0 > 94558627579744 94558633602584 9455861888 140720560866826 > 140720560866928 140720560866928 140720560869342 0 > > and copies 147058 into SLOT_pid because that code no longer knows the real > pid. > > not sure how best to fix this. Hmmm... Reasonably straightforward to fix, but my tree has local c changes in ps.c. Looks like I'm adding -m to show maximum number of lines (somebody asked, it's easy enough.) And -H to iotop (which is where I left off; need to come up with a test for this and haven't got one. Is chrome threads or processes? The big scott mccloud comic implied processes, but the way google does everything implies threads, but threads would defeat the entire VM sandboxing purpose of having each tab in its own process...) [Which is where I stopped doing the "this is simple, I should just fix it before finishing the reply..." and 3 days later that part's not done yet...] [Rob] [P.S. You can use two finger scrolling to replace a down arrow in chrome, the "j" key instead of a down arrow in vi, and hit page down and cursor back up a lot. I really should finish closing windows and shut down so I can replace the keyboard one of these days...] ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
[Toybox] ps -T
ps -T doesn't really work if you have any filters. so ps -AT is fine, but ps -p -T only shows the main thread. why? because slots[SLOT_pid] is "wrong" in shared_match_process (where by wrong i mean "is the tid"). why? because toybox reads (say) /proc/147047/task/147058/stat and sees 147058 (CompositorTileW) S 31782 6249 6249 0 -1 1077952576 4 0 0 0 0 0 0 0 20 0 11 0 1211910244 928649216 35602 18446744073709551615 94558515900416 94558627572512 140720560858928 140506510343072 140506833892356 0 0 4098 1073827581 1 0 0 -1 31 0 0 0 0 0 94558627579744 94558633602584 9455861888 140720560866826 140720560866928 140720560866928 140720560869342 0 and copies 147058 into SLOT_pid because that code no longer knows the real pid. not sure how best to fix this. -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer. ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] ps -T -o name
On Wed, May 4, 2016 at 4:44 PM, Rob Landleywrote: > > > On 05/04/2016 03:55 PM, enh wrote: >> seems like a bug that if you use -o but don't include 'tid', -T becomes a >> no-op? >> >> ps -A -T | wc -l >> ps -A -T -o name | wc -l > > The way I implemented it, > > 1) If you display tid, it fetches tid. > 2) -T changes the default fields displayed. > > I'm happy to implement different behavior, I'm just not familiar with > what it should be. i think this is new ground, but i think i can't think of a case where you'd want -o to disable the -T you provided earlier, especially because it's not completely unreasonable to want to list the threads but not want the tid. >> should this >> >> dt = dirtree_read("/proc", >> (TT.bits&(_PS_TID|_PS_TCNT)) ? get_threads : get_ps); >> >> be >> >> dt = dirtree_read("/proc", >> ((toys.optflags_T) || (TT.bits&(_PS_TID|_PS_TCNT))) ? >> get_threads : get_ps); >> >> ? > > If you think that's a good idea... > > Committed and pushed, thanks. > Rob > ___ > Toybox mailing list > Toybox@lists.landley.net > http://lists.landley.net/listinfo.cgi/toybox-landley.net -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer. ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] ps -T -o name
On 05/04/2016 03:55 PM, enh wrote: > seems like a bug that if you use -o but don't include 'tid', -T becomes a > no-op? > > ps -A -T | wc -l > ps -A -T -o name | wc -l The way I implemented it, 1) If you display tid, it fetches tid. 2) -T changes the default fields displayed. I'm happy to implement different behavior, I'm just not familiar with what it should be. > should this > > dt = dirtree_read("/proc", > (TT.bits&(_PS_TID|_PS_TCNT)) ? get_threads : get_ps); > > be > > dt = dirtree_read("/proc", > ((toys.optflags_T) || (TT.bits&(_PS_TID|_PS_TCNT))) ? > get_threads : get_ps); > > ? If you think that's a good idea... Committed and pushed, Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] ps -t is cheating.
On 10/22/2015 01:31 PM, Rob Landley wrote: On 10/20/2015 12:43 AM, lamiaworks wrote: Message: 1 Date: Mon, 19 Oct 2015 00:09:17 -0500 From: Rob Landley <r...@landley.net> To: toybox@lists.landley.net Subject: [Toybox] ps -t is cheating. Message-ID: <56247afd.5050...@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 or -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. $ ps -t 05 error: TTY could not be found with a little play I found that the /dev/ttyxx needs to exist first. also to confuse, have a look at what's written at > http://linux.die.net/man/8/makedev but that does bring some other nasty thoughts into it all sorry rob regards Linux hasn't got a /dev/tty05. It's got a /dev/tty5. But what procps's version of ps does (and thus what people are going to expect) is show pts/5 for digits. I checked in code that treats purely numeric "-t 1" as a request for /dev/pts/1 instead of /dev/tty1. To get tty1 say "-t tty1". I dunno about "right" behavior. I just know that posix is decades behind what linux is actually _doing_... My first Mainframes (1970's) had tty0 to ttyf for systems consoles I/O ONLY, and tty00 to ttyff for user terminals. That would be the decades behind part. :) 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 codeet al... Lovely. I doubt android is providing any tty devices at all, with the possible exception of an adb console, just pts devices to instances of the "terminal" program. (Which isn't a default app on any of my phones yet, but I live in hope that _someday_ I won't have to install a third party app to get what seems to be built-in functionality.) That said, the -t I checked in (yesterday?) is whitelisting specific names, and if the adb terminal isn't among them I need to either stop whitelisting (I worry that -t /dev/urandom or -t ../some/random/path will somehow be exploitable, even though all I'm really doing is stat-ing it) or add the new name... 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, Which means I really should _write_ the documentation I wanted to read, yet again. Write a properly detailed "this is what toybox implements" as an actual spec in the model of posix. Then wave it at the android and tizen guys and have them frown and disagree with bits of it. And of course fill in the tests; I haven't done proper ps tests yet because the values change, from PIDs to %cpu output, but _how_ to do so is pretty straightforward. Finite list of command line options and -o selections... Alas, my open source stuff is not my day job. (I get to do some of it on the clock, but the past couple week's been debugging nommu toolchains and such...) Going as fast as I can in the time I have... Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] ps -t is cheating.
On 10/20/2015 12:43 AM, lamiaworks wrote: > >> Message: 1 >> Date: Mon, 19 Oct 2015 00:09:17 -0500 >> From: Rob Landley <r...@landley.net> >> To: toybox@lists.landley.net >> Subject: [Toybox] ps -t is cheating. >> Message-ID: <56247afd.5050...@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 or -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. $ ps -t 05 error: TTY could not be found Linux hasn't got a /dev/tty05. It's got a /dev/tty5. But what procps's version of ps does (and thus what people are going to expect) is show pts/5 for digits. I checked in code that treats purely numeric "-t 1" as a request for /dev/pts/1 instead of /dev/tty1. To get tty1 say "-t tty1". I dunno about "right" behavior. I just know that posix is decades behind what linux is actually _doing_... > My first Mainframes (1970's) had tty0 to ttyf for systems consoles I/O > ONLY, and tty00 to ttyff for user terminals. That would be the decades behind part. :) > 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 codeet al... Lovely. I doubt android is providing any tty devices at all, with the possible exception of an adb console, just pts devices to instances of the "terminal" program. (Which isn't a default app on any of my phones yet, but I live in hope that _someday_ I won't have to install a third party app to get what seems to be built-in functionality.) That said, the -t I checked in (yesterday?) is whitelisting specific names, and if the adb terminal isn't among them I need to either stop whitelisting (I worry that -t /dev/urandom or -t ../some/random/path will somehow be exploitable, even though all I'm really doing is stat-ing it) or add the new name... >> 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, Which means I really should _write_ the documentation I wanted to read, yet again. Write a properly detailed "this is what toybox implements" as an actual spec in the model of posix. Then wave it at the android and tizen guys and have them frown and disagree with bits of it. And of course fill in the tests; I haven't done proper ps tests yet because the values change, from PIDs to %cpu output, but _how_ to do so is pretty straightforward. Finite list of command line options and -o selections... Alas, my open source stuff is not my day job. (I get to do some of it on the clock, but the past couple week's been debugging nommu toolchains and such...) Going as fast as I can in the time I have... Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] ps -t is cheating.
On Wed, Oct 21, 2015 at 7:31 PM, Rob Landley <r...@landley.net> wrote: > > > On 10/20/2015 12:43 AM, lamiaworks wrote: >> >>> Message: 1 >>> Date: Mon, 19 Oct 2015 00:09:17 -0500 >>> From: Rob Landley <r...@landley.net> >>> To: toybox@lists.landley.net >>> Subject: [Toybox] ps -t is cheating. >>> Message-ID: <56247afd.5050...@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 or -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. > > $ ps -t 05 > error: TTY could not be found > > Linux hasn't got a /dev/tty05. It's got a /dev/tty5. But what procps's > version of ps does (and thus what people are going to expect) is show > pts/5 for digits. > > I checked in code that treats purely numeric "-t 1" as a request for > /dev/pts/1 instead of /dev/tty1. To get tty1 say "-t tty1". > > I dunno about "right" behavior. I just know that posix is decades behind > what linux is actually _doing_... > >> My first Mainframes (1970's) had tty0 to ttyf for systems consoles I/O >> ONLY, and tty00 to ttyff for user terminals. > > That would be the decades behind part. :) > >> 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 codeet al... > > Lovely. > > I doubt android is providing any tty devices at all, with the possible > exception of an adb console, just pts devices to instances of the > "terminal" program. (Which isn't a default app on any of my phones yet, > but I live in hope that _someday_ I won't have to install a third party > app to get what seems to be built-in functionality.) adb and Terminal.app both just use /dev/pts/*, yes. but Android devices do tend to have a surprising number of /dev/tty* devices too. here's AOSP Nexus 9, for example: $ adb shell ls -l "/dev/tty*" crw-rw-rw- 1 root root 5, 0 2015-10-20 07:31 /dev/tty crw--- 1 root root 253, 0 2015-10-20 07:31 /dev/ttyFIQ0 crw--- 1 root root 238, 0 2015-10-20 07:31 /dev/ttyGS0 crw--- 1 root root 238, 1 2015-10-20 07:31 /dev/ttyGS1 crw--- 1 root root 238, 2 2015-10-20 07:31 /dev/ttyGS2 crw--- 1 root root 238, 3 2015-10-20 07:31 /dev/ttyGS3 crw--- 1 root root 238, 4 2015-10-20 07:31 /dev/ttyGS4 crw--- 1 root root 4, 64 2015-10-20 07:31 /dev/ttyS0 crw--- 1 root root 4, 65 2015-10-20 07:31 /dev/ttyS1 crw--- 1 root root 4, 66 2015-10-20 07:31 /dev/ttyS2 crw--- 1 root root 4, 67 2015-10-20 07:31 /dev/ttyS3 crw--- 1 root root 242, 0 2015-10-20 07:31 /dev/ttyTHS0 crw-rw 1 gps system 242, 1 2015-10-20 07:31 /dev/
Re: [Toybox] ps -t is cheating.
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 or -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". > 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
Re: [Toybox] ps -t is cheating.
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 or -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.) > 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". No need to special case numbers. This is *roughly* what procutils is doing, apart from that 'no need to special-case numbers' I'd assume. HTH, Isaac ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
[Toybox] ps -t is cheating.
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 or -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. 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... ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net