diff options
author | Niklas Hambüchen <mail@nh2.me> | 2021-05-23 16:26:34 +0200 |
---|---|---|
committer | Pascal Bach <pascal.bach@nextrem.ch> | 2021-09-03 22:26:22 +0200 |
commit | 4961547d05376023fdc7a4664aba4d933d43e7b5 (patch) | |
tree | 7ad0298671f4bc21d6b8cf958ab6bc307eedb064 /pkgs/build-support/libredirect | |
parent | 0afbd6c86a29160386e5386332b65ba707a25340 (diff) |
libredirect: Fix redirects not working for subprocesses
Diffstat (limited to 'pkgs/build-support/libredirect')
-rw-r--r-- | pkgs/build-support/libredirect/libredirect.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index dfa2978e9f440..5b0ef4856708c 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -17,15 +17,22 @@ static int nrRedirects = 0; static char * from[MAX_REDIRECTS]; static char * to[MAX_REDIRECTS]; +static int isInitialized = 0; + // FIXME: might run too late. static void init() __attribute__((constructor)); static void init() { + if (isInitialized) return; + char * spec = getenv("NIX_REDIRECTS"); if (!spec) return; - unsetenv("NIX_REDIRECTS"); + // Ensure we only run this code once. + // We do not do `unsetenv("NIX_REDIRECTS")` to ensure that redirects + // also get initialized for subprocesses. + isInitialized = 1; char * spec2 = malloc(strlen(spec) + 1); strcpy(spec2, spec); |