In a script, I am trying to retrieve some details of all processes of current user on linux (RHEL 6.4 and 5.7). I was using "ps -o pid,args,euser" for it. But I realized it was not including processes owned by same user but launched in different shell session. Then I tried "ps o pid,args,euser", it works. In man page, I could not see anything which implies such difference. What causes it?
$ ps -o 'pid,args,euser'
PID COMMAND EUSER
13491 -/usr/bin/ksh ak
13519 bash ak
25427 ps -o pid,args,euser ak
$ ps o 'pid,args,euser'
PID COMMAND EUSER
13491 -/usr/bin/ksh ak
13519 bash ak
13699 -/usr/bin/ksh ak
13727 bash ak
20573 -/usr/bin/ksh ak
20616 bash ak
20996 -bash ak
21027 screen -D -R ak
24842 /apps/ak/localdis/pub/cpyth ak
25460 ps o pid,args,euser ak
25714 -/usr/bin/ksh ak
25742 bash ak
To quote from the man page (available here via first result on Google)
... The use of BSD-style options will also change the process selection to include processes on other terminals (TTYs) that are owned by you; alternately, this may be described as setting the selection to be the set of all processes filtered to exclude processes owned by other users or not on a terminal. These effects are not considered when options are described as being "identical" below, so -M will be considered identical to Z and so on.