Skip to content

SpawnCommand.set_environment_variables vs os.getenv #6132

Answered by wez
replicaJunction asked this question in Q&A
Discussion options

You must be logged in to vote

set_environment_variables sets environment variables for the child processes that are spawned in the default execution domain. It does not set them in the wezterm process, which is what os.getenv reads.

In general, changing the environment in a running program is fraught with peril, as it leads to race conditions in multi-threaded programs, so it is something to be avoided. Also: it is impossible for one program to change the environment of another running program; you can only change your own environment, or prepare the environment to be used for a child process that you spawn, once, at the time that you spawn it.

I'm not super clear on what your higher level goal is.

If you want to decl…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@replicaJunction
Comment options

Answer selected by replicaJunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants