From 6577c186c972ad4b75e4854c8c261f6cf34bf5cc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 2 Feb 2006 19:55:45 +0000 Subject: * external.cc (setup_winenv): New function. (cygwin_internal): Implement CW_SETUP_WINENV. * sys/cygwin.h (cygwin_getinfo_types): Define CW_SETUP_WINENV. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/external.cc | 24 ++++++++++++++++++++++++ winsup/cygwin/include/sys/cygwin.h | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) 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 + + * 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 * 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 +#include 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 */ -- cgit v1.1