Getting another process' environment


 
Thread Tools Search this Thread
Top Forums Programming Getting another process' environment
# 1  
Old 03-21-2008
Getting another process' environment

Suppose that I have an environment variable (call it "EVAR") that I set before running a process (call it "myproc"). "myproc" is run multiple times by multiple users and each may set "EVAR" differently. I.E.:

UserA:
export EVAR=v1
myproc

UserB:
export EVAR=v2
myproc

Now "myproc" is running twice, each with different values of "EVAR". Now, let us say that I have another application, "qryproc" who can find all instances of "myproc" that are running. However, for "qryproc" to do its job, it needs to know what "EVAR" looks like for each instance of "myproc" it knows about.

Is this doable? Assume that "qryproc" will be running as root.

Thanks for any ideas....
# 2  
Old 03-21-2008
Your method is flawed imo.
Given that, you could handle this several ways off the top of my head using sockets or strictly sys v ipc. A named pipe seems like a workable solution.

If I 'had' to do it this way I would use signals, a shared memory segment and semaphore set.
# 3  
Old 03-25-2008
I think you can use argv[] for specifying arguments and it can be read by 'ps' and equivalent methods.

If you really need to use ENV then the program can copy suitable information to argv[1] (which must have proper length for that) and the rest is the same as above.
# 4  
Old 04-02-2008
I did not want "qryproc" to have to talk directly to "myproc" (via some IPC method) because that would require me to change every different flavor of "myproc" in our system to be capable of making its data available to "qryproc".

Barring any suggestions how to tap into a non-modified "myproc" and extract its environment, I guess I'll have no choice but to make "myproc" and "qryproc" able to talk to one another.

Edit: also, I have simplified the problem, EVAR is just a single piece of the environment, "qryproc" wants to be capable of seeing "all of it." (I.E. "myproc" uses a bunch of environment variables to configure itself and I need "qryproc" to deterime how each instance "myproc" it knows about is currently configured).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies

3. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

4. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

5. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

6. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

7. HP-UX

How can I get environment of running process?!!

In Solaris, here is the command that use to get the environments of running process. pargs -e For example: /export/home/admin> pargs -e 6682 6682: /storage1/opt/wls103/jdk160_05/bin/java -client -Xms256m -Xmx512m -XX:CompileTh envp: XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt envp:... (1 Reply)
Discussion started by: obbzung
1 Replies

8. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

9. AIX

3004-505 Cannot set process environment

Guys I have an AIX 5.3 box.I am getting following messages if i try to switch to any non root user. bash-3.00# su - sys 3004-505 Cannot set process environment. bash-3.00# su - daemon 3004-505 Cannot set process environment. bash-3.00# su - adm 3004-505 Cannot set process environment.... (4 Replies)
Discussion started by: ak835
4 Replies

10. UNIX for Advanced & Expert Users

Reset environment - ".. /etc/.environment dev_env"

I have been resently working on some ksh script. One of the line in the file writes: .. /etc/.environment dev_env I can not understand what this mean, all I know is .environment is unix system environment file. Is ".." a command? If some one can give me some clue where can I find information... (7 Replies)
Discussion started by: zzwu3591
7 Replies
Login or Register to Ask a Question