Linux.com

carthell

carthell

  • Linux.com Member
  • Posts: 1
  • Member Since: 30 Apr
  • Last Logged In: 30 Apr

Latest Posts

Posted by
Topic
Post Preview
Posted
  • carthell
    RE: environment variable in linux gcc
    Many UNIX-based (and other) systems create a child process to run programs, so any changes that you make will affect only the environment running your program, not the process (terminal window) that started the program. You can see what I mean by running "ps" in a terminal/shell window: one process listing will show the name of the shell running in your terminal window, while the other listing shows the "ps" command. I'm just getting back into a UNIX-type environment (yay, Mint!), so the only solutions to your problem that I remember is by (ugh! ugh!) running a root-level program that can manipulate system memory; or run a script or program that initializes the environment variables that you want to manipulate in a child process, then start another child process that will work with the environment variables. Example: #this is a script that sets up the variables that program "foo" will manipulate. set RESULT1=' ' set RESULT2='0' ~/foo echo $RESULT1 echo $RESULT2 # end shell script Write a program (foo) that changes the environment variables, and the value of the changed variables will stay in effect until the shell script ends.
    Link to this post 30 Apr

    Many UNIX-based (and other) systems create a child process to run programs, so any changes that you make will affect only the environment running your program, not the process (terminal window) that started the program. You can see what I mean by running "ps" in a terminal/shell window: one process listing will show the name of the shell running in your terminal window, while the other listing shows the "ps" command.

    I'm just getting back into a UNIX-type environment (yay, Mint!), so the only solutions to your problem that I remember is by (ugh! ugh!) running a root-level program that can manipulate system memory; or run a script or program that initializes the environment variables that you want to manipulate in a child process, then start another child process that will work with the environment variables.

    Example:

    #this is a script that sets up the variables that program "foo" will manipulate.
    set RESULT1=' '
    set RESULT2='0'
    ~/foo
    echo $RESULT1
    echo $RESULT2
    # end shell script

    Write a program (foo) that changes the environment variables, and the value of the changed variables will stay in effect until the shell script ends.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board