How does 'screen' impact environment variables?

11,684

A process inherits the environment variables from the parent, this means the first time you call screen (create a new one) it has a copy of all the environment variables of the parent process. Now screen adjusts/creates some variables like COLUMNS, LINES, TERM, TERMCAP, WINDOW and STY. You can also adjust or delete environment variables in your screenrc with setenv/unsetenv.

On some systems, screen is setuid or setgid in order to update utmp and wtmp; then a few more variables are removed from the environment when screen starts, such as LD_LIBRARY_PATH.

If you attach to an existing screen session your environment variables won't be copied as the screen process already exists and has it own environment variables (from the time when you started the process before). This means your changed environment variables won't be visible in the processes started by screen as they are copied from the parent process which has the old environment variables.

Share:
11,684

Related videos on Youtube

Kevin Lee
Author by

Kevin Lee

If it isn't on the internet, it may not actually exist. I believe that sites like Stack Overflow do a wonderful service in filling in knowledge gaps for programming. What good is a result if it's not meant to be shared?

Updated on September 18, 2022

Comments