From 17e5cc91a7d6b9096471e045208522e05aa6c498 Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Sun, 17 Nov 2013 02:29:00 +0100 Subject: [PATCH] fix Issue 11112 - Unable to execute shell commands in different threads - the environPtr initializer was only called for the main thread --- std/internal/processinit.d | 4 ++-- std/process.d | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/std/internal/processinit.d b/std/internal/processinit.d index 9012704fe47..79df0e767d9 100644 --- a/std/internal/processinit.d +++ b/std/internal/processinit.d @@ -13,10 +13,10 @@ module std.internal.processinit; version(OSX) { - extern(C) void std_process_static_this(); + extern(C) void std_process_shared_static_this(); shared static this() { - std_process_static_this(); + std_process_shared_static_this(); } } diff --git a/std/process.d b/std/process.d index 801036d85d6..4bed599aca6 100644 --- a/std/process.d +++ b/std/process.d @@ -153,8 +153,8 @@ version (Posix) version (OSX) { extern(C) char*** _NSGetEnviron() nothrow; - private const(char**)* environPtr; - extern(C) void std_process_static_this() { environPtr = _NSGetEnviron(); } + private __gshared const(char**)* environPtr; + extern(C) void std_process_shared_static_this() { environPtr = _NSGetEnviron(); } const(char**) environ() @property @trusted nothrow { return *environPtr; } } else @@ -162,6 +162,11 @@ version (Posix) // Made available by the C runtime: extern(C) extern __gshared const char** environ; } + + unittest + { + new Thread({assert(environ !is null);}).start(); + } }