Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-09-2005, 05:56 AM   #1
LQ Newbie
Registered: Jan 2003
Distribution: Gentoo
Posts: 8

Rep: Reputation: 0
How to change environment variables of a parent envrionment from a child one.

I have the folowing scenario:

I login. This starts BASH, with the proper environment; let's call this enviroment MAIN ENVIRONMENT; it has the folowing variables definiton: x=x_main; y=y_main. Now i issue startx. Everithing it's fine, works as i expect. Now i start xterm for example. From this, I want to change a environment variable from MAIN ENVIRONMENT, without closing a sinle window, nor X. Is here any way to do this?

The problem is that i want to cahnge the enviroment variables, and the changes to be reflected in every new started application, this without loging out, closing a windows or something...
Old 11-09-2005, 06:24 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Each process has a copy of the environment, so you can't change variable values of the parent's and siblings' processes after the fact. You can use the .profile or .bash_login scripts to change variables in the future, or alter them where they are defined (such as in a script in /etc/sysconfig).

Some variables are re-evaluated on the fly using functions, and for other variables, you may need to restart a service so they can be loaded in again.

One example, is HOSTNAME. While there is a "hostname" command that will reflect a recent change in your configuration, KDE will not work properly until you log out and back in again.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
GCC fork() - Can a child change a parent variable? johnhardey Programming 4 03-10-2005 10:49 AM
parent and child processes skora Programming 5 11-02-2003 10:41 AM
about parent and child process winwar Solaris / OpenSolaris 3 07-23-2003 06:07 AM
environment variables change in X Baloney Pete Slackware 1 01-19-2003 02:40 PM
Must change environment variables rw Linux - General 6 07-11-2001 11:17 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration