3

I could find a process named typora from htop

enter image description here

but I cannot trace it from ps or pstree

$ ps -a | grep -i typora
 9696 ttys003    0:00.01 grep -i typora

$ pstree | grep -i typora 
 |     |--- 09713 me grep -i typora
 |--= 00258 me /Applications/Typora.app/Contents/MacOS/Typora -psn_0_40970

How could I find it from command ps.

1
  • Have you try ps -efl | grep -i typora? Nov 6, 2018 at 6:40

2 Answers 2

11

From the ps manual on macOS (my emphasis):

-a

Display information about other users' processes as well as your own. This will skip any processes which do not have a controlling terminal, unless the -x option is also specified.

Applications that are running on macOS without a controlling terminal, such as windowed Finder applications, will not be listed by ps -a. To list these, use ps -ax.

Or, you may may use the -A or -e option:

-A

Display information about other users' processes, including those without controlling terminals.

-e

Identical to -A.

If you are looking for information about a process with a particular name, consider using pgrep instead:

pgrep Typora

(note that case matters, unless you use pgrep -i)

To signal a process with a particular name, use pkill rather than trying to grep the output of ps.

See the manuals for pgrep and pkill.

Also, even though this was not part of your question, pstree has a -s option to show only the branches of the process tree that contains processes with a particular name.

1
  • Or use POSIX ps -A. MacOS being a UNIX certified system, I'd expect ps -e would work as well. Nov 6, 2018 at 7:22
1

Short answer is: add to ps switch H. From man: H Show threads as if they were processes.

Long answer is down.

I am aware that this, 5 years old, question is answered and answer is accepted, but, from one hand I am not very satisfied with it and on second hand let me bring variant, which, I hope, will be helpful.

htop is showing processes along with their threads, which can be easily checked by pressing t in interactive mode or initially by option "-t --tree Show the tree view".

As typora is not free now, then as example I had used command mate-terminal. First call creates process, while subsequent calls creates threads from first. So, after simple htop we have

enter image description here

After pressing t

enter image description here

When we used command ps axu , for example, we see only first process and we cannot see threads, but they are listed under /proc/<pid>/task/.

enter image description here

To see also threads we can use H switch in BSD stile, so ps axuH will show process with its threads and now we can see the same picture, which we have in htop

enter image description here

Described behavior is not necessary and is inherent to mate-terminal and, as I guess, to typora. For example each call of konsole crates new process and is seen as under htop, so by ps axu.

Answer is tested in debian 11.6.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .