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
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 13 03-06-2009 07:33 AM
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 07: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 01:54 PM
Reset environment - ".. /etc/.environment dev_env" zzwu3591 UNIX for Advanced & Expert Users 7 01-12-2007 09: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-05-2006 03:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-21-2008
DreamWarrior DreamWarrior is offline
Registered User
  
 

Join Date: Oct 2003
Posts: 70
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 (permalink)  
Old 03-21-2008
ramen_noodle ramen_noodle is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 251
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 (permalink)  
Old 03-25-2008
odys odys is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 59
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 (permalink)  
Old 04-02-2008
DreamWarrior DreamWarrior is offline
Registered User
  
 

Join Date: Oct 2003
Posts: 70
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).
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0