Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2018-06-06 18:45:56 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-06-07 10:42:36 +0300
commitdefaa2ca31cd3e407451d55ea8414f30d7dddf65 (patch)
tree8165cf77c3608bc9a5719557138bb2be8019f541 /winsup
parent9234545e3d84a873e1c1a6faff28cfb55320a248 (diff)
Cygwin: Implement the GNU extension clearenv
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/common.din1
-rw-r--r--winsup/cygwin/environ.cc20
-rw-r--r--winsup/cygwin/include/cygwin/stdlib.h3
3 files changed, 24 insertions, 0 deletions
diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index 6e8bf9185..426cf172c 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
@@ -306,6 +306,7 @@ cimag NOSIGFE
cimagf NOSIGFE
cimagl NOSIGFE
cleanup_glue NOSIGFE
+clearenv SIGFE
clearerr SIGFE
clearerr_unlocked SIGFE
clock SIGFE
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 06e1ced01..bbe539816 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -720,6 +720,26 @@ unsetenv (const char *name)
return -1;
}
+/* Clear the environment. */
+extern "C" int
+clearenv (void)
+{
+ __try
+ {
+ if (cur_environ () == lastenviron)
+ {
+ free (lastenviron);
+ lastenviron = NULL;
+ }
+ __cygwin_environ = NULL;
+ update_envptrs ();
+ return 0;
+ }
+ __except (EFAULT) {}
+ __endtry
+ return -1;
+}
+
/* Minimal list of Windows vars which must be converted to uppercase.
Either for POSIX compatibility of for backward compatibility with
existing applications. */
diff --git a/winsup/cygwin/include/cygwin/stdlib.h b/winsup/cygwin/include/cygwin/stdlib.h
index 845d2d81b..e274b8b94 100644
--- a/winsup/cygwin/include/cygwin/stdlib.h
+++ b/winsup/cygwin/include/cygwin/stdlib.h
@@ -26,6 +26,9 @@ char *canonicalize_file_name (const char *);
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
int unsetenv (const char *);
#endif
+#if __MISC_VISIBLE
+int clearenv (void);
+#endif
#if __XSI_VISIBLE
char *ptsname (int);
int grantpt (int);