LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   who - man pages (https://www.linuxquestions.org/questions/programming-9/who-man-pages-416421/)

kshkid 02-17-2006 05:09 AM

who - man pages
 
Hi All,

When I went through the man pages of who regarding the listing of PID's

the PID displayed is the pid of the user's current shell

Code:

who -uH
When I tried that on solaris,
only the PID of the login program which spawned the users-shell is displayed and not the pid of users-shell

This is really confusing.

Could you please explain it?

MensaWater 02-18-2006 02:39 PM

Can't answer that but if you want to see all processes owned by a specific user you can type:

ps -fu<username>

If you want to see all processes associated with a certain terminal (tty/pty) type:
ps -ft<terminal>

Either of the above will show you the user's shell and all other processes for that user (in case of username) or on that user's terminal (in the case of terminal).

The reason you might want to use the latter is that the user may have multiple logins and you may only be interested in what one of those logins is doing. Also this will let you see if the user has changed users with the su command as the process for the switched user will still be associated with the terminal.

kshkid 02-19-2006 11:15 PM

thanks for the reply,

but I am afraid the answer you had posted is no where thinking of question that I had posted.

My intention is not about listing of process.
I would just like to clarify regarding the statement in the
man pages of who and
the output generated

I hope am clear with the question once again.

bigearsbilly 02-20-2006 03:35 AM

Works ok-ish for me on solaris.
comes up with -ksh and FvwmConsole

that's who for you though. It never does what you want.

kshkid 02-20-2006 07:21 AM

tried for the same reading the UTMP structure
but still the same output

could somebody please try the same on their sun boxes?
and please point me if I am wrong in my code.
Code:

# include<utmpx.h>

int main()
{
  struct utmpx *obj;
  setutxent();
  while( (obj=(struct utmpx *)getutxent()) != NULL )
  {
    (void) printf("USER: %s PID:%d\n", obj->ut_user, obj->ut_pid);
  }
  return 0;
}


bigearsbilly 02-20-2006 07:40 AM

here's my output.
SunOS primadtpdev 5.8 Generic_108528-20 sun4u sparc SUNW,Ultra-250

Code:

billym.primadtpdev>1
USER:  PID:0
USER:  PID:0
USER: rc2 PID:61
USER: rc3 PID:283
USER: sac PID:368
USER: LOGIN PID:369
USER: zsmon PID:376
USER: LOGIN PID:387
USER: billym PID:15825
USER: billym PID:6724
USER: billym PID:10182
USER: billym PID:15846
USER: billym PID:15872
USER: bdsuser PID:16139
USER: billym PID:16288
USER: billym PID:17178
USER: billym PID:17188
USER: billym PID:24488
USER: billym PID:24517
USER: bdsuser PID:28615
USER: billym PID:11194
USER: bdsuser PID:5127
USER: billym PID:4152
USER: billym PID:4161
USER: billym PID:736
USER: billym PID:10235
USER: billym PID:8500
USER: billym PID:24145
USER: billym PID:4777
USER: billym PID:24197
USER: billym PID:25086
USER: root PID:25393
USER: billym PID:25610
USER: billym PID:4330
USER: billym PID:4333
USER: billym PID:4336
USER: billym PID:4339
USER: billym PID:4342
USER: billym PID:4351
USER: billym PID:4354
USER: billym PID:4357
USER: billym PID:4368
USER: billym PID:4374
USER: billym PID:4377
USER: billym PID:4380
USER: billym PID:4383


kshkid 02-20-2006 08:17 AM

thanks bigearsbilly,

but it would have been great and helpful
if you could please post the discription of the PID's listed
whether they are PID's of the login program or that of the shell's

bigearsbilly 02-20-2006 08:32 AM

a bit like this:

Code:

billym.primadtpdev>1 | cut -f3 -d:|xargs -n1 ps -fp|sort -u
    UID  PID  PPID  C    STIME TTY      TIME CMD
    root    0    0  0  Jan 03 ?        0:01 sched
    root  368    1  0  Jan 03 ?        0:00 /usr/lib/saf/sac -t 300
    root  369    1  0  Jan 03 console  0:00 /usr/lib/saf/ttymon -g -h -p primadtpdev console login:  -T sun -d /dev/console
    root  376  368  0  Jan 03 ?        0:00 /usr/lib/saf/ttymon
    root  387  309  0  Jan 03 ?        0:00 /usr/dt/bin/dtlogin -daemon
  billym 15846 15845  0 09:06:25 pts/5    0:01 -ksh
  billym 15872 15871  0 09:11:59 pts/6    0:00 /usr/local/libexec/fvwm/2.4.19/FvwmConsoleC
  billym 16288 16286  0 11:25:27 pts/8    0:00 /usr/bin/rlogin primaappliv
  billym 17178 17176  0 13:18:47 pts/9    0:00 /usr/bin/rlogin primadtpliv
  billym 17188 17186  0 13:19:06 pts/10  0:00 /usr/bin/rlogin primadtpliv
 bdsuser 16139 16138  0 10:40:14 pts/7    0:00 -ksh


jlliagre 02-20-2006 08:40 AM

"who -uH" on Solaris is correctly giving me the logged users shell's pids.
Code:

NAME      LINE        TIME          IDLE    PID  COMMENTS
jlliagre  console      Feb 20 11:09  0:37    326
jlliagre  pts/1        Feb 20 11:24  1:19    972      (:0.0)
jlliagre  pts/2        Feb 20 11:34  0:10    999      (:0.0)
guest      pts/6        Feb 20 15:40  .    2197      (localhost)


bigearsbilly 02-20-2006 08:45 AM

I'm connecting to my solaris using an Exceed X server on a dos machine.
Maybe that throws it off.

jlliagre 02-20-2006 08:52 AM

kshkid, can you post the "who -uH" output on your machine, and the PIDs it outputs that are confusing ?

schneidz 02-20-2006 12:59 PM

Quote:

Originally Posted by bigearsbilly
I'm connecting to my solaris using an Exceed X server on a dos machine.
Maybe that throws it off.

i hate humingbird exceed (too bloaty) why dont you like putty?

sorry this isnt related.

but i sometimes see difeernces in the rows returned by w and who. maybe w does what you are expecting?

kshkid 02-21-2006 08:16 AM

here is the output

Code:

NAME      LINE        TIME          IDLE    PID  COMMENTS
kshk    pts/24      Feb 20 05:18  .    28956      (105.7.4.10)

Code:

root 28956 28953  0  Feb 20 pts/24  0:00 login -p -d /dev/pts/24 -h 105.7.4.10
and the process id of the shell,
28957

MensaWater 02-21-2006 09:37 AM

Quote:

i hate humingbird exceed (too bloaty) why dont you like putty?
PuTTY is for doing ssh connections. Exceed is for displaying X Windows connections.

You're correct for terminals there's not a lot of difference. However you can initiate the session from the server side on an X Window and also give it tons more options than you can a standard PuTTY window. However I mainly use Exceed for a lot of the other X Windows one has from Unix/Linux. I wouldn't be able to display a browser from my Linux workstation to my Windows through PuTTY but can with Exceed. A lot of the admin tools on HP-UX (which are superior to Solaris' hodge-podge of tools IHMO) have both a text based and GUI version and generally like using the latter.

jlliagre 02-21-2006 10:19 AM

Can you give the full process stack of this process (pstack 28956), I suspect the command is launched by something like "xterm -e login -p ...".


All times are GMT -5. The time now is 12:00 AM.