Folks,
How can I change the process/command name (argv[0]) in Solaris 9
so that ps command displays a different name?
On AIX I can change argv[0] on HP I can use pstat.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
|
|
0
|
|
|
|
Reply
|
Hemant
|
9/2/2003 4:25:50 PM |
|
In article <bj2gae$cud$1@flood.xnet.com>,
Hemant Shah <shah@typhoon.xnet.com> writes:
>
> Folks,
>
> How can I change the process/command name (argv[0]) in Solaris 9
> so that ps command displays a different name?
>
> On AIX I can change argv[0] on HP I can use pstat.
You can't, so that /usr/bin/ps can see it - /usr/bin/ps looks at a saved
copy of the first 80 characters of the args as they were when the
program was exec'd. That's so that the process can't hide as something
else, and because it's easier and more reliable to fetch that than to
dig the args out of the process's address space.
However, /usr/ucb/ps looks into the process to see the args as it sees
them; for instance, if you have sendmail running, compare how it looks
with
/usr/bin/ps -fpSENDMAIL_PID
and
/usr/ucb/ps auxwww SENDMAIL_PID
You could get the code for sendmail and find out how it does that.
I think you'd want initsetproctitle() and setproctitle() in
sendmail-VERSION/sendmail/conf.c
(in the above, substitute for SENDMAIL_PID and VERSION
as appropriate)
--
mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
|
|
0
|
|
|
|
Reply
|
Richard
|
9/2/2003 5:07:56 PM
|
|
While stranded on information super highway Richard L. Hamilton wrote:
:)In article <bj2gae$cud$1@flood.xnet.com>,
:) Hemant Shah <shah@typhoon.xnet.com> writes:
:)>
:)> Folks,
:)>
:)> How can I change the process/command name (argv[0]) in Solaris 9
:)> so that ps command displays a different name?
:)>
:)> On AIX I can change argv[0] on HP I can use pstat.
:)
:)You can't, so that /usr/bin/ps can see it - /usr/bin/ps looks at a saved
:)copy of the first 80 characters of the args as they were when the
:)program was exec'd. That's so that the process can't hide as something
:)else, and because it's easier and more reliable to fetch that than to
:)dig the args out of the process's address space.
:)
:)However, /usr/ucb/ps looks into the process to see the args as it sees
:)them; for instance, if you have sendmail running, compare how it looks
:)with
:)/usr/bin/ps -fpSENDMAIL_PID
:)
:)and
:)
:)/usr/ucb/ps auxwww SENDMAIL_PID
:)
:)You could get the code for sendmail and find out how it does that.
:)I think you'd want initsetproctitle() and setproctitle() in
:)sendmail-VERSION/sendmail/conf.c
:)
:)(in the above, substitute for SENDMAIL_PID and VERSION
:)as appropriate)
Thank you. As long as Sun supports /usr/ucb/ps it will work for us.
Our application runs several transactions and we change the command/process
name so they are easy to identify. On sun I changed argv[0] and
/usr/ucb/ps displays the new value where as /bin/ps displays the original
values.
:)
:)--
:)mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
|
|
0
|
|
|
|
Reply
|
Hemant
|
9/2/2003 7:04:01 PM
|
|
In article <bj2pj1$g8i$1@flood.xnet.com>, shah@typhoon.xnet.com says...
> While stranded on information super highway Richard L. Hamilton wrote:
> :)In article <bj2gae$cud$1@flood.xnet.com>,
> :) Hemant Shah <shah@typhoon.xnet.com> writes:
> :)>
> :)> Folks,
> :)>
> :)> How can I change the process/command name (argv[0]) in Solaris 9
> :)> so that ps command displays a different name?
> :)>
> :)> On AIX I can change argv[0] on HP I can use pstat.
> :)
> :)You can't, so that /usr/bin/ps can see it - /usr/bin/ps looks at a saved
> :)copy of the first 80 characters of the args as they were when the
> :)program was exec'd. That's so that the process can't hide as something
> :)else, and because it's easier and more reliable to fetch that than to
> :)dig the args out of the process's address space.
> :)
> :)However, /usr/ucb/ps looks into the process to see the args as it sees
> :)them; for instance, if you have sendmail running, compare how it looks
> :)with
> :)/usr/bin/ps -fpSENDMAIL_PID
> :)
> :)and
> :)
> :)/usr/ucb/ps auxwww SENDMAIL_PID
> :)
> :)You could get the code for sendmail and find out how it does that.
> :)I think you'd want initsetproctitle() and setproctitle() in
> :)sendmail-VERSION/sendmail/conf.c
> :)
> :)(in the above, substitute for SENDMAIL_PID and VERSION
> :)as appropriate)
>
>
> Thank you. As long as Sun supports /usr/ucb/ps it will work for us.
>
> Our application runs several transactions and we change the command/process
> name so they are easy to identify. On sun I changed argv[0] and
> /usr/ucb/ps displays the new value where as /bin/ps displays the original
> values.
>
>
> :)
> :)--
> :)mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
>
>
If you're good at programming, you can actually change it (because no
applications will write at that area, so there is no memory lock
problems).
Here is how you do this by hand:
First, lets choose one process, with its Process info Address:
# ps -efo pid,addr,comm
PID ADDR COMMAND
0 104239f8 sched
1 30000b374f8 /etc/init
879 300013c0af0 mibiisa <----- THIS IS OUR PROCESS
992 300013d0ae8 /usr/lib/saf/ttymon
....
....
First, you must see address of our ARGS string from process U-area, and
then you replace it (all nonimportant output is deleted)
# adb -kw /dev/ksyms /dev/kmem
physmem f258
300013c0af0$<proc2u
....
....
300013c0fb0: psargs mibiisa -r -p 32793
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@
300013c1000: comm mibiisa^@^@^@^@^@^@^@^@^@^@
....
....
300013c0fb0/30s
300013c0fb0: mibiisa -r -p 32793
300013c0fb0/W65
300013c0fb0: 0x6d696269 = 0x65
$q
# ps -efo pid,addr,comm
PID ADDR COMMAND
0 104239f8 sched
1 30000b374f8 /etc/init
879 300013c0af0
992 300013d0ae8 /usr/lib/saf/ttymon
Hope it helps (I hope you will first test it on non-production system :)
Alex
|
|
0
|
|
|
|
Reply
|
ales
|
9/3/2003 5:34:54 AM
|
|
While stranded on information super highway ales.romaniuk@mobitel.si wrote:
:)In article <bj2pj1$g8i$1@flood.xnet.com>, shah@typhoon.xnet.com says...
:)> While stranded on information super highway Richard L. Hamilton wrote:
:)> :)In article <bj2gae$cud$1@flood.xnet.com>,
:)> :) Hemant Shah <shah@typhoon.xnet.com> writes:
:)> :)>
:)> :)> Folks,
:)> :)>
:)> :)> How can I change the process/command name (argv[0]) in Solaris 9
:)> :)> so that ps command displays a different name?
:)> :)>
:)> :)> On AIX I can change argv[0] on HP I can use pstat.
:)> :)
:)> :)You can't, so that /usr/bin/ps can see it - /usr/bin/ps looks at a saved
:)> :)copy of the first 80 characters of the args as they were when the
:)> :)program was exec'd. That's so that the process can't hide as something
:)> :)else, and because it's easier and more reliable to fetch that than to
:)> :)dig the args out of the process's address space.
:)> :)
:)> :)However, /usr/ucb/ps looks into the process to see the args as it sees
:)> :)them; for instance, if you have sendmail running, compare how it looks
:)> :)with
:)> :)/usr/bin/ps -fpSENDMAIL_PID
:)> :)
:)> :)and
:)> :)
:)> :)/usr/ucb/ps auxwww SENDMAIL_PID
:)> :)
:)> :)You could get the code for sendmail and find out how it does that.
:)> :)I think you'd want initsetproctitle() and setproctitle() in
:)> :)sendmail-VERSION/sendmail/conf.c
:)> :)
:)> :)(in the above, substitute for SENDMAIL_PID and VERSION
:)> :)as appropriate)
:)>
:)>
:)> Thank you. As long as Sun supports /usr/ucb/ps it will work for us.
:)>
:)> Our application runs several transactions and we change the command/process
:)> name so they are easy to identify. On sun I changed argv[0] and
:)> /usr/ucb/ps displays the new value where as /bin/ps displays the original
:)> values.
:)>
:)>
:)> :)
:)> :)--
:)> :)mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
:)>
:)>
:)If you're good at programming, you can actually change it (because no
:)applications will write at that area, so there is no memory lock
:)problems).
:)Here is how you do this by hand:
:)
:)First, lets choose one process, with its Process info Address:
:)# ps -efo pid,addr,comm
:) PID ADDR COMMAND
:) 0 104239f8 sched
:) 1 30000b374f8 /etc/init
:) 879 300013c0af0 mibiisa <----- THIS IS OUR PROCESS
:) 992 300013d0ae8 /usr/lib/saf/ttymon
:)...
:)...
:)
:)First, you must see address of our ARGS string from process U-area, and
:)then you replace it (all nonimportant output is deleted)
:)# adb -kw /dev/ksyms /dev/kmem
:)physmem f258
:)300013c0af0$<proc2u
:)...
:)...
:)300013c0fb0: psargs mibiisa -r -p 32793
:)^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
:)
:)^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
:) ^@^@^@^@^@^@^@^@^@^@
:)300013c1000: comm mibiisa^@^@^@^@^@^@^@^@^@^@
:)...
:)...
:)300013c0fb0/30s
:)300013c0fb0: mibiisa -r -p 32793
:)300013c0fb0/W65
:)300013c0fb0: 0x6d696269 = 0x65
:)$q
:)# ps -efo pid,addr,comm
:) PID ADDR COMMAND
:) 0 104239f8 sched
:) 1 30000b374f8 /etc/init
:) 879 300013c0af0
:) 992 300013d0ae8 /usr/lib/saf/ttymon
:)
:)
:)
:)
:)
:)
:)
:)Hope it helps (I hope you will first test it on non-production system :)
:)Alex
This won't work for us because we need to do this dynamically while the
process it running.
Example: When we start the server it runs a process (ServerProc.ServerName),
The name of the executable is server.
When the user connects to the ServerProc it forks a process
(we call it UserProc.UserName).
When user runs a transaction UserProc forks another process (we call
it TransProc.UserName.TranName).
We need to change the name after the process is created. We change argv[0]
after the processes is created.
If we use /usr/bin/ps or /bin/ps we get
server
server
server
server
server
If we use /usr/ucb/ps we get
ServerProc.H105
UserProc.shah
TransProc.shah.ADM1
UserProc.potter
TransProc.potter.ADM1
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
|
|
0
|
|
|
|
Reply
|
Hemant
|
9/3/2003 4:51:32 PM
|
|
In article <bj566k$h6q$1@flood.xnet.com>, shah@typhoon.xnet.com says...
> his won't work for us because we need to do this dynamically while the
> process it running.
>
But I didn't mean you would do this via adb. I wanted to show you
structures and the way to do it manually. If you know PID (you know it
as a result from fork()), and you're root (hope you are), then you can
use library calls (see man kvm_getproc()) to get information about
process.
# more sys/proc.h
typedef struct proc {
/*
* Fields requiring no explicit locking
*/
struct vnode *p_exec; /* pointer to a.out vnode */
struct as *p_as; /* process address space pointer
*/
....
....
struct user p_user; /* (see sys/user.h) */
....
....
# more sys/user.h
....
....
char u_psargs[PSARGSZ]; /* arguments from exec */
char u_comm[MAXCOMLEN + 1];
....
....
Well, I never made a program for doing this, I had just searched for you
right now. Perhaps is only a science fiction :) to do this, but you can
try it.
Regards
|
|
0
|
|
|
|
Reply
|
Glodalec
|
9/3/2003 8:18:01 PM
|
|
In article <MPG.19c0587b150c5b79989723@news.siol.net>,
Glodalec <glodalec@yahoo.com> writes:
> In article <bj566k$h6q$1@flood.xnet.com>, shah@typhoon.xnet.com says...
>> his won't work for us because we need to do this dynamically while the
>> process it running.
>>
> But I didn't mean you would do this via adb. I wanted to show you
> structures and the way to do it manually. If you know PID (you know it
> as a result from fork()), and you're root (hope you are), then you can
> use library calls (see man kvm_getproc()) to get information about
> process.
>
> # more sys/proc.h
> typedef struct proc {
> /*
> * Fields requiring no explicit locking
> */
> struct vnode *p_exec; /* pointer to a.out vnode */
> struct as *p_as; /* process address space pointer
> */
> ...
> ...
> struct user p_user; /* (see sys/user.h) */
> ...
> ...
>
> # more sys/user.h
> ...
> ...
> char u_psargs[PSARGSZ]; /* arguments from exec */
> char u_comm[MAXCOMLEN + 1];
> ...
> ...
>
> Well, I never made a program for doing this, I had just searched for you
> right now. Perhaps is only a science fiction :) to do this, but you can
> try it.
Of course you can do this - either as a new library routine or as a
loadable system call (notwithstanding that the interface for those is
undocumented). But it subverts the _intentional_ difference between
/usr/bin/ps and /usr/ucb/ps in that regard, and I don't think that's a good
thing (and of course writing into kernel storage isn't a real good idea
anyway; some kernel patch could come along and break it big time, at which
point you'd be wondering why you were crashing, corrupting files, etc.)
There's no question that it's theoretically possible, but that doesn't
necessarily make it sensible.
--
mailto:rlhamil@mindwarp.smart.net http://www.smart.net/~rlhamil
|
|
0
|
|
|
|
Reply
|
Richard
|
9/3/2003 9:58:19 PM
|
|
While stranded on information super highway Glodalec wrote:
:)In article <bj566k$h6q$1@flood.xnet.com>, shah@typhoon.xnet.com says...
:)> his won't work for us because we need to do this dynamically while the
:)> process it running.
:)>
:)But I didn't mean you would do this via adb. I wanted to show you
:)structures and the way to do it manually. If you know PID (you know it
:)as a result from fork()), and you're root (hope you are), then you can
:)use library calls (see man kvm_getproc()) to get information about
:)process.
Thanks. I will take a look at the man page and try it out.
:)
:)# more sys/proc.h
:)typedef struct proc {
:) /*
:) * Fields requiring no explicit locking
:) */
:) struct vnode *p_exec; /* pointer to a.out vnode */
:) struct as *p_as; /* process address space pointer
:)*/
:)...
:)...
:)struct user p_user; /* (see sys/user.h) */
:)...
:)...
:)
:)# more sys/user.h
:)...
:)...
:) char u_psargs[PSARGSZ]; /* arguments from exec */
:) char u_comm[MAXCOMLEN + 1];
:)...
:)...
:)
:)Well, I never made a program for doing this, I had just searched for you
:)right now. Perhaps is only a science fiction :) to do this, but you can
:)try it.
:)
:)Regards
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
|
|
0
|
|
|
|
Reply
|
Hemant
|
9/4/2003 12:48:13 AM
|
|
|
7 Replies
710 Views
(page loaded in 0.127 seconds)
Similiar Articles: Change process/command name? - comp.unix.solarisFolks, How can I change the process/command name (argv[0]) in Solaris 9 so that ps command displays a different name? On AIX I can change ... man pages for /usr/ucb - comp.unix.solarisChange process/command name? - comp.unix.solaris However, /usr/ucb/ps looks into the process to see the args as it sees them; for ... I will take a look at the man page ... Discovering printers IP address... - comp.unix.solaris... using Solaris) discover Printer s IP address, issuing any command ?(giving to Solaris printer s name ... comp.protocols.snmp hood county driver license address change hood ... How does a scrpt find its process id when under cron ? - comp.unix ...Change process/command name? - comp.unix.solaris:)Here is how you do this by hand: :) :)First, lets choose one process, with its Process ... How can you determine if ... bind: Address already in use - comp.unix.solarisAccessing "u area" of a process - comp.unix.programmer Change process/command name? - comp.unix.solaris:) :)First, you must see address of ... DaviS* wrote: > Hi all ... get umask of existing process? - comp.unix.solarisI have process that is ... SunOS <machine-name> 5 ... The umask shell command changes the umask of the shell process, and all processes subsequently ... chmod used to change ... How can you determine if Daylight Savings is in effect in a script ...... at 3:00 everyday and we need to process them quickly. Our customers observe the DST change ... to catch the TZ time via the dat command ... of file with customer and TZ name ... how to send control-break or ctrl-c signal to background process ...(You might also be interested to know that Control-Z sends a SIGTSTP signal to a process.) If you want, you can change ... Archive-name: cdrom/cd-recordable/part1 Posting ... EMERGENCY: process die but the port is still listening - comp.unix ...My process has die, but the port 7066 ... kill the PID: # lsof -i :25 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ... Life is a series of change, grow or ... su password not working - comp.unix.solarisCan view the bootup process though Kermit and a > null ... but since I can't log in as su I can't edit or > > change ... Searching ... the caps lock key pressed when you enter ... stupefy developer: linux: change the process' nameFrom time to time developers want to modify the command line of program that is shown in ps or top utilities. There is no API in linux to modify the ... Process - AutoHotkey... PID) or a process name as described below. It can also be left blank to change ... The Process command itself can also be used to discover a PID. Name: The name of a process ... 7/23/2012 7:29:12 AM
|