Thursday, September 7, 2017

bash - What does command line arguments mean in pstree -a option




When read the manual of pstree



 -a     Show command line arguments.  If the command line of a process is swapped  out,  that  process  is
shown in parentheses. -a implicitly disables compaction for processes but not threads.


I am very confused about 'command line arguments'



Compare the output




me@alpha:~$ pstree |head -5
systemd-+-ModemManager---2*[{ModemManager}]
|-NetworkManager-+-dhclient
| `-2*[{NetworkManager}]
|-accounts-daemon---2*[{accounts-daemon}]
|-acpid
me@alpha:~$ pstree -a | head -5
systemd splash
|-ModemManager --filter-policy=strict

| `-2*[{ModemManager}]
|-NetworkManager --no-daemon
| |-dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /run/dhclient-wlp3s0.pid -lf...


Command lines are composed of function, options and arguments



Say -a show command line arguments, implies that others just show funtions and options, but that is not the case.



What does the command line arguments mean here?




Command-line arguments, in general, refers to all arguments after the name of the program being run. For example, in your command pstree | head -5, there is one argument to head which is -5.



In the pstree output, the tree consists of a root of either a pid (process ID) or init, and then the tree of children threads. For example, in your output, NetworkManager is a parent process that is running one dhclient and 2 NetworkManager threads.



Adding the -a flag also prints the arguments that were used when each process or thread was started. For example, in your output, we can see that NetworkManager was started with one argument --no-daemon, and likewise dhclient was started with several arguments.



That is all the man page means by "show command line arguments".


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...