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
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/resource.cc25
2 files changed, 33 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index cc4916596..87160a7fc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+Thu Jan 5 9:33:00 2001 Corinna Vinschen <corina@vinschen.de>
+
+ * resource.cc (getrlimit): Set errno on EFAULT instead of returning
+ it.
+ (setrlimit): Ditto.
+
+Thu Jan 5 3:38:00 2001 David Sainty <David.Sainty@optimation.co.nz>
+
+ * resource.cc (setrlimit): Prevent failing with an error when the
+ operation would not have changed anything.
+
Thu Jan 4 10:29:54 2001 Earnie Boyd <earnie_boyd@yahoo.com>
* thread.cc: Need LONG_MAX definition.
diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index e8e53d110..cb1fc222a 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -1,6 +1,6 @@
/* resource.cc: getrusage () and friends.
- Copyright 1996, 1997, 1998, 2000 Cygnus Solutions.
+ Copyright 1996, 1997, 1998, 2000, 2001 Cygnus Solutions.
Written by Steve Chamberlain (sac@cygnus.com), Doug Evans (dje@cygnus.com),
Geoffrey Noer (noer@cygnus.com) of Cygnus Support.
@@ -106,7 +106,10 @@ getrlimit (int resource, struct rlimit *rlp)
{
MEMORY_BASIC_INFORMATION m;
if (!rlp || !VirtualQuery (rlp, &m, sizeof (m)) || (m.State != MEM_COMMIT))
- return EFAULT;
+ {
+ set_errno (EFAULT);
+ return -1;
+ }
rlp->rlim_cur = RLIM_INFINITY;
rlp->rlim_max = RLIM_INFINITY;
@@ -139,7 +142,23 @@ setrlimit (int resource, const struct rlimit *rlp)
{
MEMORY_BASIC_INFORMATION m;
if (!rlp || !VirtualQuery (rlp, &m, sizeof (m)) || (m.State != MEM_COMMIT))
- return EFAULT;
+ {
+ set_errno (EFAULT);
+ return -1;
+ }
+
+ struct rlimit oldlimits;
+
+ // Check if the request is to actually change the resource settings.
+ // If it does not result in a change, take no action and do not
+ // fail.
+ if (getrlimit(resource, &oldlimits) < 0)
+ return -1;
+
+ if (oldlimits.rlim_cur == rlp->rlim_cur &&
+ oldlimits.rlim_max == rlp->rlim_max)
+ // No change in resource requirements, succeed immediately
+ return 0;
switch (resource)
{