-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ability to pass custom environments to processes #1
Comments
Yeah its on my TODO list (in my head) - worry not! |
Quick question - it's not thread safe to inherit the environment of the parent and have the child process append to the environment of the parent process's environment. Would it be ok for your usecases that the child process would not inherit the parent's environment, and instead if you wanted that as a user you'd have to pass along the environment variables yourself? |
That isn't the approach you would do. The process construction methods themselves allow you to pass an environment list, when you pass NULL they inherit by default the parent's environment. On windows this would be done by creating an environment block which is just a single block of string separated by null terminator characters. The end of the block must be an empty string (so the block end has two null termination characters.). On POSIX systems there's two ways, the easy way and the correct way, the easy way would be to just pass everything through |
Right but the issue is that if you specify any environment variables at all then any environment variables that were set in the parent are not passed down. I'm thinking of the case where you want to spawn a process but specify |
That isn't a useful operation. You can always read the parents's environment and copy them when you make your list before spawning the child process. This is actually required on Windows because Window's environment block does not permit you to override an environment variable that is already in the block. If you have |
Gotya! Glad we had some back and forth on this, I'm pretty sure we're on the same page now 😄 I think I'll add some option flags var that controls whether you inherit the parents environment or not - at present we are always inheriting which doesn't seem great! |
As the first part of this, I've created an MR that allows you to specify whether the parent environment should be inherited or not #6. I'll then do a follow-up for setting individual environment variables. |
I also needed this feature on Linux and created a quick an dirty way to pass the env variables. The environment variables are ignored when the inherit option is set. The approach that I took can be found here: As a note: |
This commit adds `subprocess_create_ex` which has an additional argument `environment` that lets you specify the environment for the spawned process. Fixes #1.
This commit adds `subprocess_create_ex` which has an additional argument `environment` that lets you specify the environment for the spawned process. Fixes #1.
This commit adds `subprocess_create_ex` which has an additional argument `environment` that lets you specify the environment for the spawned process. Fixes #1.
This commit adds `subprocess_create_ex` which has an additional argument `environment` that lets you specify the environment for the spawned process. Fixes #1.
would be nice if you could pass custom environments to the processes by passing a list of environment variable strings or NULL to inherit the current processes environment.
The text was updated successfully, but these errors were encountered: