@@ -148,8 +148,8 @@ private
148
148
{
149
149
version (Darwin)
150
150
{
151
- extern (C ) char *** _NSGetEnviron() nothrow ;
152
- const (char ** ) getEnvironPtr () @trusted
151
+ extern (C ) char *** _NSGetEnviron() @nogc nothrow ;
152
+ const (char ** ) getEnvironPtr () @trusted @nogc nothrow
153
153
{
154
154
return * _NSGetEnviron;
155
155
}
@@ -158,7 +158,7 @@ private
158
158
{
159
159
// Made available by the C runtime:
160
160
extern (C ) extern __gshared const char ** environ;
161
- const (char ** ) getEnvironPtr () @trusted
161
+ const (char ** ) getEnvironPtr () @trusted @nogc nothrow
162
162
{
163
163
return environ;
164
164
}
@@ -1119,7 +1119,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
1119
1119
}
1120
1120
1121
1121
// Execute program.
1122
- core.sys.posix.unistd.execve (argz[0 ], argz.ptr, envz);
1122
+ core.sys.posix.unistd.execve (argz[0 ], argz.ptr, envz is null ? getEnvironPtr : envz );
1123
1123
1124
1124
// If execution fails, exit as quickly as possible.
1125
1125
abortOnError(forkPipeOut, InternalError.exec, .errno);
@@ -1421,7 +1421,7 @@ private Pid spawnProcessWin(scope const(char)[] commandLine,
1421
1421
// on the form "name=value", optionally adding those of the current process'
1422
1422
// environment strings that are not present in childEnv. If the parent's
1423
1423
// environment should be inherited without modification, this function
1424
- // returns environ directly .
1424
+ // returns null .
1425
1425
version (Posix )
1426
1426
private const (char * )* createEnv (const string [string ] childEnv,
1427
1427
bool mergeWithParentEnv)
@@ -1431,7 +1431,7 @@ private const(char*)* createEnv(const string[string] childEnv,
1431
1431
auto environ = getEnvironPtr;
1432
1432
if (mergeWithParentEnv)
1433
1433
{
1434
- if (childEnv.length == 0 ) return environ ;
1434
+ if (childEnv.length == 0 ) return null ;
1435
1435
while (environ[parentEnvLength] != null ) ++ parentEnvLength;
1436
1436
}
1437
1437
@@ -1461,16 +1461,7 @@ version (Posix) @system unittest
1461
1461
assert (e1 != null && * e1 == null );
1462
1462
1463
1463
auto e2 = createEnv(null , true );
1464
- assert (e2 != null );
1465
- int i = 0 ;
1466
- auto environ = getEnvironPtr;
1467
- for (; environ[i] != null ; ++ i)
1468
- {
1469
- assert (e2[i] != null );
1470
- import core.stdc.string : strcmp;
1471
- assert (strcmp(e2[i], environ[i]) == 0 );
1472
- }
1473
- assert (e2[i] == null );
1464
+ assert (e2 == null );
1474
1465
1475
1466
auto e3 = createEnv([" foo" : " bar" , " hello" : " world" ], false );
1476
1467
assert (e3 != null && e3[0 ] != null && e3[1 ] != null && e3[2 ] == null );
0 commit comments