The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell Programming and Scripting 1 02-15-2008 03:10 PM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
Reset environment - ".. /etc/.environment dev_env" zzwu3591 UNIX for Advanced & Expert Users 7 01-12-2007 05:27 AM
my process is going to sleep mode after 12 hours but i need my process in in firsy pr mukesh_rakesh1 UNIX for Advanced & Expert Users 0 09-04-2006 11:43 PM
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 11 07-12-2005 12:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-21-2008
Registered User
 

Join Date: Oct 2003
Posts: 69
Stumble this Post!
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....
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-21-2008
Registered User
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 238
Stumble this Post!
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.
Reply With Quote
  #3 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Feb 2005
Posts: 52
Stumble this Post!
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.
Reply With Quote
  #4 (permalink)  
Old 04-02-2008
Registered User
 

Join Date: Oct 2003
Posts: 69
Stumble this Post!
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).
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0