@@ -1205,7 +1205,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
1205
1205
}
1206
1206
1207
1207
// Execute program.
1208
- core.sys.posix.unistd.execve (argz[0 ], argz.ptr, envz);
1208
+ core.sys.posix.unistd.execve (argz[0 ], argz.ptr, envz is null ? getEnvironPtr : envz );
1209
1209
1210
1210
// If execution fails, exit as quickly as possible.
1211
1211
abortOnError(forkPipeOut, InternalError.exec, .errno);
@@ -1511,7 +1511,7 @@ private Pid spawnProcessWin(scope const(char)[] commandLine,
1511
1511
// on the form "name=value", optionally adding those of the current process'
1512
1512
// environment strings that are not present in childEnv. If the parent's
1513
1513
// environment should be inherited without modification, this function
1514
- // returns environ directly .
1514
+ // returns null .
1515
1515
version (Posix )
1516
1516
private const (char * )* createEnv (const string [string ] childEnv,
1517
1517
bool mergeWithParentEnv)
@@ -1521,7 +1521,7 @@ private const(char*)* createEnv(const string[string] childEnv,
1521
1521
auto environ = getEnvironPtr;
1522
1522
if (mergeWithParentEnv)
1523
1523
{
1524
- if (childEnv.length == 0 ) return environ ;
1524
+ if (childEnv.length == 0 ) return null ;
1525
1525
while (environ[parentEnvLength] != null ) ++ parentEnvLength;
1526
1526
}
1527
1527
@@ -1551,16 +1551,7 @@ version (Posix) @system unittest
1551
1551
assert (e1 != null && * e1 == null );
1552
1552
1553
1553
auto e2 = createEnv(null , true );
1554
- assert (e2 != null );
1555
- int i = 0 ;
1556
- auto environ = getEnvironPtr;
1557
- for (; environ[i] != null ; ++ i)
1558
- {
1559
- assert (e2[i] != null );
1560
- import core.stdc.string : strcmp;
1561
- assert (strcmp(e2[i], environ[i]) == 0 );
1562
- }
1563
- assert (e2[i] == null );
1554
+ assert (e2 == null );
1564
1555
1565
1556
auto e3 = createEnv([" foo" : " bar" , " hello" : " world" ], false );
1566
1557
assert (e3 != null && e3[0 ] != null && e3[1 ] != null && e3[2 ] == null );
0 commit comments