Re: controlling terminal - to have and have not
On Fri, Jan 07, 2022 at 05:08:16PM +0100, Jan Stary wrote: > This is how ps(1) differentiates between displaying > processes that have a terminal and those that have not: > > -a Display information about processes > for all users with controlling terminals. > > -x Display information about processes > without controlling terminals. > > Strangely, some processes appear in both listings: > > $ ps -a | grep man > 22867 p6 Ip 0:00.02 man ps > 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ > 43736 p7 R+p/30:00.00 grep man > > $ ps -x | grep man > 22867 p6 Ip 0:00.02 man ps > 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ > 50867 p7 R+p/20:00.05 grep man > > Is this intended? Am I missing something obvious? > Or does the wording mean "users with controlling terminals"? > > Jan > > The man page should say something like: -a include processes other than your own, but skip processes without controlling terminal, unless -x is also specified -x include processes without controlling terminal. -Otto
Re: controlling terminal - to have and have not
On Fri, Jan 07, 2022 at 05:08:16PM +0100, Jan Stary wrote: > This is how ps(1) differentiates between displaying > processes that have a terminal and those that have not: > > -a Display information about processes > for all users with controlling terminals. > > -x Display information about processes > without controlling terminals. > > Strangely, some processes appear in both listings: > > $ ps -a | grep man > 22867 p6 Ip 0:00.02 man ps > 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ > 43736 p7 R+p/30:00.00 grep man > > $ ps -x | grep man > 22867 p6 Ip 0:00.02 man ps > 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ > 50867 p7 R+p/20:00.05 grep man > > Is this intended? Am I missing something obvious? > Or does the wording mean "users with controlling terminals"? -x doesn't limit the display to ONLY processes with controlling terminals, it includes them in addition to the processes that would otherwise be listed. Have a look at ps.c, the code is quite straightforward. The -a and -x options just set the all and xflg flags, which are tested later on when the list of processes is parsed.
controlling terminal - to have and have not
This is how ps(1) differentiates between displaying processes that have a terminal and those that have not: -a Display information about processes for all users with controlling terminals. -x Display information about processes without controlling terminals. Strangely, some processes appear in both listings: $ ps -a | grep man 22867 p6 Ip 0:00.02 man ps 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ 43736 p7 R+p/30:00.00 grep man $ ps -x | grep man 22867 p6 Ip 0:00.02 man ps 82326 p6 I+p 0:00.02 less -T /tmp/man.TkUznrbk0K /tmp/man.qGVXE5xsvJ 50867 p7 R+p/20:00.05 grep man Is this intended? Am I missing something obvious? Or does the wording mean "users with controlling terminals"? Jan