HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getting refreshed Env Variable value in Child proc...
Operating System - HP-UX
1830899
Members
3380
Online
110017
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2002 09:12 PM
12-05-2002 09:12 PM
Getting refreshed Env Variable value in Child process??
I have a process mfasys_call (code given below) which calls a application "mfasys". I have to set some Environment Variable in mfasys_call which should be available to the application mfasys. I make use of putenv function to set the environment variable in mfasys_call and use system() call in mfasys to get that environment variable value. This works fine normally.
Now my requirement is that mfasys sends SIGUSR1 which mfasys_call traps and changes the value of environment variable. However this changed value is not accessible within the mfasys. It retrieves the original value only. Is there any way to make the mfasys process get the latest updated value of environment variable set in mfasys_call (mfasys_call is parent of mfasys process).
void main()
{
char sEnvStr[30];
sprintf(sEnvStr, "MYPID=%d", getpid());
putenv(sEnvStr);
signal(SIGUSR1, sig_catch);
system("mfasys");
}
static void sig_catch(int sig)
{
char sEnvStr2[30];
sprintf(sEnvStr2, "MYPID=1111");
putenv(sEnvStr2);
}
Now my requirement is that mfasys sends SIGUSR1 which mfasys_call traps and changes the value of environment variable. However this changed value is not accessible within the mfasys. It retrieves the original value only. Is there any way to make the mfasys process get the latest updated value of environment variable set in mfasys_call (mfasys_call is parent of mfasys process).
void main()
{
char sEnvStr[30];
sprintf(sEnvStr, "MYPID=%d", getpid());
putenv(sEnvStr);
signal(SIGUSR1, sig_catch);
system("mfasys");
}
static void sig_catch(int sig)
{
char sEnvStr2[30];
sprintf(sEnvStr2, "MYPID=1111");
putenv(sEnvStr2);
}
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2002 10:12 PM
12-05-2002 10:12 PM
Re: Getting refreshed Env Variable value in Child process??
The simple answer is NO. At the moment a child process is created, it inherits A COPY OF the perent's environment variables. From then on, they are two separate processes, and changes made to one's environment do not, in any way, affect the other.
A small kludge would be to communicate the new parameters across to your child process using IPC - shared memory or named pipe. An easier but less reliable workaround would be to use a scratch file accessible by both processes.
A small kludge would be to communicate the new parameters across to your child process using IPC - shared memory or named pipe. An easier but less reliable workaround would be to use a scratch file accessible by both processes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2002 04:05 AM
12-06-2002 04:05 AM
Re: Getting refreshed Env Variable value in Child process??
Hi Amit:
Using a temp file would be an easy way to do it.
It looks like the shmget(2)and shmctl(2) commands should work if you want to use shared memory.
Tom
Using a temp file would be an easy way to do it.
It looks like the shmget(2)and shmctl(2) commands should work if you want to use shared memory.
Tom
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP