Operating System - HP-UX
1821626 Members
3153 Online
109633 Solutions
New Discussion юеВ

how to find effective gid of running process

 
SOLVED
Go to solution
John Kittel
Trusted Contributor

how to find effective gid of running process

How can I find the gid of a running process?

( actually, the effective gid at the time the process was started)

I've been looking for a way to use the ps command. The ps man page says the gid and group columns in the output give this info, but none of the ps output format options described in the man page actually generate those columns in the output. Unles of course I'm missing something...

- John
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: how to find effective gid of running process

Since users are commonly members of multiple groups, its hard to see what this output can do for you.

What you can do is take the owner of the process and then get the primary gid of the user.

user=$(ps -ef | grep xxx | awk '{ print $1)')
# tweak required untested

gid=$(cat /etc/group | grep -i user | awk '{ print $3 }')

SEP
# this output will
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
John Kittel
Trusted Contributor

Re: how to find effective gid of running process

forgot to mention, HP-UX 11i, on rp2470.

- John
Helen French
Honored Contributor
Solution

Re: how to find effective gid of running process

You need to make use of the UNIX95 command with ps:

# export UNIX95=XPG4
# ps -ef -o user -o pid -o comm -o rgid -o gid

Where you will get real group ID from rgid and effective group ID from gid columns.
Life is a promise, fulfill it!
Kevin Wright
Honored Contributor

Re: how to find effective gid of running process

Unix95, use the XPG4 option with the ps command. It's documented in the man page.

get GID
export UNIX95=XPG4
ps -efj
John Kittel
Trusted Contributor

Re: how to find effective gid of running process

reason I desire this output:

1) vendor's software started at boot via rc script gets started as root:root, but then vendor's GUI started from command line runs as root:sys and refuses to deal with the process because the effective gid is different. I work around this by running newgrp to change root's effective gid before running the GUI.

2) same vendor, application refuses to let user write to directory using (secondary) user group membership, only looks at users primary group.

3) current problem, same vendor, not sure what the cause is but guessing it is similar to 1 and 2 above, ... if their app is started at boot by rc script, then when user tries to connect to server there is a licensing problem, which I can get around by restarting the app from the command line. I'm suspecting that once again the effective gid at startup is not what their licensing daemon wants to see.

- John
Kevin Wright
Honored Contributor

Re: how to find effective gid of running process

sorry, you didn't want pgid, you wanted effective gid of user..

ps -ef -o uid,comm,gid will give it to you.
John Kittel
Trusted Contributor

Re: how to find effective gid of running process

thanks for responses. I'll test suggestions and assign points shortly,... just got called to "emergency" meeting with boss so I'll have to get back to this later...

- John