Friday Jul 16, 2010

Process Arguments and Environment Variables

If you want to quickly determine the arguments or environment variables used by a process, pargs, one of a handful of very useful proc tools, is for you.

For example, NetBeans is started with a bunch of arguments. Rather than hunting through the netbeans configuration files, I can locate netbeans' process id:

bleonard@opensolaris:~$ ps -ef | grep netbeans
bleonard  5215     1   0 17:35:16 ?           0:00 /bin/bash /usr/netbeans/bin/../platform10/lib/nbexec --userdir /export/home/ble
Then simply run:
bleonard@opensolaris:~$ pargs 5215
5215:	/bin/bash /usr/netbeans/bin/../platform10/lib/nbexec --userdir /export/home/ble
argv[0]: /bin/bash
argv[1]: /usr/netbeans/bin/../platform10/lib/nbexec
argv[2]: --userdir
argv[3]: /export/home/bleonard/.netbeans/6.7
argv[4]: --jdkhome
argv[5]: /usr/java
argv[6]: --branding
argv[7]: nb
argv[8]: --clusters
argv[9]: /usr/netbeans/nb6.7:/usr/netbeans/ergonomics1:/usr/netbeans/ide11:/usr/netbeans/java2:/usr/netbeans/bin/../xml2:/usr/netbeans/apisupport1:/usr/netbeans/webcommon1:/usr/netbeans/websvccommon1:/usr/netbeans/enterprise5:/usr/netbeans/bin/../mobility8:/usr/netbeans/profiler3:/usr/netbeans/ruby2:/usr/netbeans/bin/../python1:/usr/netbeans/php1:/usr/netbeans/bin/../visualweb2:/usr/netbeans/bin/../soa2:/usr/netbeans/identity2:/usr/netbeans/bin/../uml6:/usr/netbeans/harness:/usr/netbeans/cnd2:/usr/netbeans/dlight1:/usr/netbeans/groovy1:/usr/netbeans/bin/../extra:/usr/netbeans/bin/../javafx2:
argv[10]: -J-Dnetbeans.importclass=org.netbeans.upgrade.AutoUpgrade
argv[11]: -J-Dnetbeans.accept_license_class=org.netbeans.license.AcceptLicense
argv[12]: -J-Xmx512m
argv[13]: -J-client
argv[14]: -J-Xss2m
argv[15]: -J-Xms32m
argv[16]: -J-XX:PermSize=32m
argv[17]: -J-XX:MaxPermSize=200m
argv[18]: -J-Xverify:none
argv[19]: -J-Dapple.laf.useScreenMenuBar=true
argv[20]: -J-Dsun.java2d.noddraw=true

To see the environment variables available to a process, use the -e option. For example, here are some of the relevant variables used by sqlplus:

bleonard@opensolaris:~$ pargs -e `pgrep sqlplus`
7114:	sqlplus
envp[0]: ORACLE_HOME=/export/home/bleonard/Download/instantclient_11_2
...
envp[12]: LD_LIBRARY_PATH=/export/home/bleonard/Download/instantclient_11_2
...
envp[48]: _=/export/home/bleonard/Download/instantclient_11_2/sqlplus

About

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
21
22
23
24
25
26
27
28
29
30
   
       
Today