Operating System - HP-UX
1753925 Members
8485 Online
108810 Solutions
New Discussion

command name shown by ps command

 
Jdamian
Respected Contributor

command name shown by ps command

Hi.

(I found this issue)

As you know some commands as 'ps' changes their behaviour when the environment variable UNIX95 is set.

I read in man pages that 'ps' command can show the 'command name' or the 'arguments' in the output according to '-o' option: For example:

UNIX95= ps -e -o comm
UNIX95= ps -e -o args

The most of people will assume that both outputs match... but it is not true because some commands change their names when launched, for instance, RAID manager instances.

When a RAID Manager instace is running, the running process name (instance) matches the extended regular expression
horcmd_[[:digit:]]+
for example horcmd_03.
To check if this process is running I type:
ps -ef | grep horcmd_
But I was surprised when I type d a slight variation of previous command line and found nothing:
ps -e | grep horcmd_03
I checked the PID and found that, in the second output, the running process (horcmd_03) is shown as 'horcmgr', not as 'horcmd_03'.

I inquired into this problem and found that the running process is actually launched by 'horcmgr' binary file.

I know that the running processes are create in two steps: fork() system call and exec() system call. exec() system calls allow to change the name of process name (argv[0] in C-syntax).

Then I understand that 'args' in 'ps' commands means 'argv[0], argv[1], ...) whereas 'comm' means 'original name of launched command'. '-f' and '-l' options are opposed in this aspect according to manual pages:

-f Show columns user, pid, ppid, cpu, stime, tty, time, and args, in that order.

-l Show columns flags, state, uid, pid, ppid, cpu, intpri, nice, addr, sz, wchan, tty, time, and comm, in that order.

The problem is that this assumptions is not true when UNIX95 is set because:

UNIX95= ps -e -o args

and

UNIX95= ps -e -o comm

show the 'args' not the 'comm', i.e, both preceding command lines show the same output...

I think this can be a bug.
What do you think ?

1 REPLY 1
Jdamian
Respected Contributor

Re: command name shown by ps command

sorry... the nearest paragraphs above and below the command lines

UNIX95= ps -e -o comm
UNIX95= ps -e -o args

at the beginning of my discussion, are wrong.

Then ignore the following paragraphs:

"I read in man pages that 'ps' command can show the 'command name' or the 'arguments' in the output according to '-o' option: For example:

UNIX95= ps -e -o comm
UNIX95= ps -e -o args

The most of people will assume that both outputs match... but it is not true because some commands change their names when launched, for instance, RAID manager instances."