aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-02-02 19:55:45 +0000
committerChristopher Faylor <me@cgf.cx>2006-02-02 19:55:45 +0000
commit6577c186c972ad4b75e4854c8c261f6cf34bf5cc (patch)
tree29065d8de0a96af66433bb3c5cd9896d8f2cbc39
parentbb6f800d1840dfb870fa5af01c5884317330bdf6 (diff)
downloadnewlib-6577c186c972ad4b75e4854c8c261f6cf34bf5cc.zip
newlib-6577c186c972ad4b75e4854c8c261f6cf34bf5cc.tar.gz
newlib-6577c186c972ad4b75e4854c8c261f6cf34bf5cc.tar.bz2
* external.cc (setup_winenv): New function.
(cygwin_internal): Implement CW_SETUP_WINENV. * sys/cygwin.h (cygwin_getinfo_types): Define CW_SETUP_WINENV.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/external.cc24
-rw-r--r--winsup/cygwin/include/sys/cygwin.h3
3 files changed, 32 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7d75b8a..8e50fd6 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-02 Christopher Faylor <cgf@timesys.com>
+
+ * external.cc (setup_winenv): New function.
+ (cygwin_internal): Implement CW_SETUP_WINENV.
+ * sys/cygwin.h (cygwin_getinfo_types): Define CW_SETUP_WINENV.
+
2006-02-02 Corinna Vinschen <corinna@vinschen.de>
* security.cc (is_group_member): Fix comment.
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index dc83f7b..3e593e4 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -28,7 +28,9 @@ details. */
#include "pwdgrp.h"
#include "cygtls.h"
#include "child_info.h"
+#include "environ.h"
#include <unistd.h>
+#include <stdlib.h>
child_info *get_cygwin_startup_info ();
@@ -133,6 +135,25 @@ check_ntsec (const char *filename)
return allow_ntsec && pc.has_acls ();
}
+/* Copy cygwin environment variables to the Windows environment. */
+static void
+setup_winenv ()
+{
+ char **envp = __cygwin_environ;
+ char *var, *val;
+ char dummy;
+
+ while (envp && *envp)
+ {
+ var = strdup (*envp++);
+ val = strchr (var, '=');
+ *val++ = '\0';
+ if (!GetEnvironmentVariable (var, &dummy, 1))
+ SetEnvironmentVariable (var, val);
+ free (var);
+ }
+}
+
extern "C" unsigned long
cygwin_internal (cygwin_getinfo_types t, ...)
{
@@ -312,6 +333,9 @@ cygwin_internal (cygwin_getinfo_types t, ...)
error_start_init (va_arg (arg, const char *));
try_to_debug ();
break;
+ case CW_SETUP_WINENV:
+ setup_winenv ();
+ return 0;
default:
break;
}
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index fe4aea4..0e177e9 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -85,7 +85,8 @@ typedef enum
CW_HOOK,
CW_ARGV,
CW_ENVP,
- CW_DEBUG_SELF
+ CW_DEBUG_SELF,
+ CW_SETUP_WINENV
} cygwin_getinfo_types;
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */