std.process.system and friends

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 7 18:56:36 PST 2013


On Thu, 07 Feb 2013 20:45:49 -0500, Ali Çehreli <acehreli at yahoo.com> wrote:

> On 02/07/2013 04:37 PM, Peter Sommerfeld wrote:
>  > Ali Çehreli wrote:
>  >
>  >> On 02/07/2013 02:58 PM, Peter Sommerfeld wrote:
>  >>
>  >> > The point is you cannot *set* the path variable.
>  >> > But meanwhile I think it isn't a good idea anyway.
>  >> > The PATH belongs to the user/system, not to programs.
>  >> > Otherwise that may introduce some harm...
>  >>
>  >> The environment is private to the running process (unless some of the
>  >> variables are "exported" to child processes of that process.) There  
> is
>  >> no danger of affecting the system.
>  >
>  > Regarding the PATH win7 seems not to thinks so. May be on *nix?
>  >
>  > Peter
>
> We are talking about changing the PATH environment variable from inside  
> a program right? I don't use win7 so I have to take your word for it but  
> I am very surprised.

"exporting" is a feature of the shell in unix.  Exporting means that the
variable will be copied to child processes, and does NOT affect parent
processes or any other processes.  It is private to the process, and is
"passed on" to children (via one of the exec functions).  If the parent
changes the variable after passing to the child, the child's copy does not
change.

Windows is actually EXACTLY the same, except you don't use getenv and  
putenv, you use SetEnvironmentVariable and GetEnvironmentVariable.  You  
can use the former if you want to use the C compatibility layer, but  
that's only if you use all compatibility layer functions for everything  
(executing processes etc.)

See here  
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx

Likely the reason why the call is failing is because of an incorrect  
implementation in phobos.

-Steve


More information about the Digitalmars-d-learn mailing list