Need help with setting env variable inside system call

I have two processes. I want to set an environment variable in one process and check it in another in my C program.

1
2
3
4
5
6
7
8
9
//process 1
 if(count> 1)
 {
   system("export MORE_MSG_TO_COME=true");
 }
 else
 {
   system("export MORE_MSG_TO_COME=false");		
 }



1
2
3
4
5
6
//process 2

if($MORE_MSG_TO_COME) //not sure how to check it
{
  //do something
}


Following are the questions.
1. Is it correct method to set env variable inside system call?
2. Is the scope visible to both the process? If not, then how do I do it?

Any help will be greatly appreciated. :) I am pretty new to this so haven't tried it before.
Environments are inherited, it's not a global resource. The two apps can't communicate that way. You'll have to resort to a traditional IPC mechanism.
Topic archived. No new replies allowed.